@webex/web-client-media-engine 3.8.5 → 3.10.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.
- package/dist/cjs/index.js +2131 -2047
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2130 -2047
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +23 -4
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -30,7 +30,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
30
30
|
PERFORMANCE OF THIS SOFTWARE.
|
|
31
31
|
***************************************************************************** */
|
|
32
32
|
|
|
33
|
-
function __awaiter$
|
|
33
|
+
function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
34
34
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
35
35
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
36
36
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -352,7 +352,7 @@ var DeviceKind;
|
|
|
352
352
|
* media has successfully been obtained.
|
|
353
353
|
*/
|
|
354
354
|
function getUserMedia(constraints) {
|
|
355
|
-
return __awaiter$
|
|
355
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
356
356
|
return navigator.mediaDevices.getUserMedia(constraints);
|
|
357
357
|
});
|
|
358
358
|
}
|
|
@@ -376,7 +376,7 @@ function getDisplayMedia(constraints) {
|
|
|
376
376
|
* fulfilled.
|
|
377
377
|
*/
|
|
378
378
|
function enumerateDevices() {
|
|
379
|
-
return __awaiter$
|
|
379
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
380
380
|
return navigator.mediaDevices.enumerateDevices();
|
|
381
381
|
});
|
|
382
382
|
}
|
|
@@ -398,7 +398,7 @@ function setOnDeviceChangeHandler$1(handler) {
|
|
|
398
398
|
* @returns Array of Permission Status objects.
|
|
399
399
|
*/
|
|
400
400
|
function checkNavigatorPermissions(deviceKinds) {
|
|
401
|
-
return __awaiter$
|
|
401
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
402
402
|
const permissionRequests = [];
|
|
403
403
|
if (deviceKinds.includes(DeviceKind.VideoInput)) {
|
|
404
404
|
permissionRequests.push(navigator.permissions.query({ name: 'camera' }));
|
|
@@ -416,7 +416,7 @@ function checkNavigatorPermissions(deviceKinds) {
|
|
|
416
416
|
* @returns True if device permissions exist, false if otherwise.
|
|
417
417
|
*/
|
|
418
418
|
function checkDevicePermissions(deviceKinds) {
|
|
419
|
-
return __awaiter$
|
|
419
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
420
420
|
try {
|
|
421
421
|
const permissions = yield checkNavigatorPermissions(deviceKinds);
|
|
422
422
|
if (permissions.every((permission) => permission.state === 'granted')) {
|
|
@@ -446,7 +446,7 @@ function checkDevicePermissions(deviceKinds) {
|
|
|
446
446
|
* @returns The callback's response.
|
|
447
447
|
*/
|
|
448
448
|
function ensureDevicePermissions(deviceKinds, callback) {
|
|
449
|
-
return __awaiter$
|
|
449
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
450
450
|
try {
|
|
451
451
|
const hasDevicePermissions = yield checkDevicePermissions(deviceKinds);
|
|
452
452
|
if (!hasDevicePermissions) {
|
|
@@ -482,15 +482,15 @@ var media = /*#__PURE__*/Object.freeze({
|
|
|
482
482
|
ensureDevicePermissions: ensureDevicePermissions
|
|
483
483
|
});
|
|
484
484
|
|
|
485
|
-
var
|
|
486
|
-
(function (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
})(
|
|
485
|
+
var WebrtcCoreErrorType;
|
|
486
|
+
(function (WebrtcCoreErrorType) {
|
|
487
|
+
WebrtcCoreErrorType["DEVICE_PERMISSION_DENIED"] = "DEVICE_PERMISSION_DENIED";
|
|
488
|
+
WebrtcCoreErrorType["CREATE_STREAM_FAILED"] = "CREATE_STREAM_FAILED";
|
|
489
|
+
})(WebrtcCoreErrorType || (WebrtcCoreErrorType = {}));
|
|
490
490
|
/**
|
|
491
|
-
* Represents a
|
|
491
|
+
* Represents a WebRTC core error, which contains error type and error message.
|
|
492
492
|
*/
|
|
493
|
-
class
|
|
493
|
+
class WebrtcCoreError {
|
|
494
494
|
/**
|
|
495
495
|
* Creates new error.
|
|
496
496
|
*
|
|
@@ -501,7 +501,8 @@ class WcmeError {
|
|
|
501
501
|
this.type = type;
|
|
502
502
|
this.message = message;
|
|
503
503
|
}
|
|
504
|
-
}
|
|
504
|
+
}
|
|
505
|
+
|
|
505
506
|
/**
|
|
506
507
|
* Creates a camera stream. Please note that the constraint params in second getUserMedia call would NOT take effect when:
|
|
507
508
|
*
|
|
@@ -513,13 +514,13 @@ class WcmeError {
|
|
|
513
514
|
* @returns A LocalCameraStream object or an error.
|
|
514
515
|
*/
|
|
515
516
|
function createCameraStream(constructor, constraints) {
|
|
516
|
-
return __awaiter$
|
|
517
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
517
518
|
let stream;
|
|
518
519
|
try {
|
|
519
520
|
stream = yield getUserMedia({ video: Object.assign({}, constraints) });
|
|
520
521
|
}
|
|
521
522
|
catch (error) {
|
|
522
|
-
throw new
|
|
523
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create camera stream: ${error}`);
|
|
523
524
|
}
|
|
524
525
|
return new constructor(stream);
|
|
525
526
|
});
|
|
@@ -532,13 +533,13 @@ function createCameraStream(constructor, constraints) {
|
|
|
532
533
|
* @returns A LocalMicrophoneStream object or an error.
|
|
533
534
|
*/
|
|
534
535
|
function createMicrophoneStream(constructor, constraints) {
|
|
535
|
-
return __awaiter$
|
|
536
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
536
537
|
let stream;
|
|
537
538
|
try {
|
|
538
539
|
stream = yield getUserMedia({ audio: Object.assign({}, constraints) });
|
|
539
540
|
}
|
|
540
541
|
catch (error) {
|
|
541
|
-
throw new
|
|
542
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create microphone stream: ${error}`);
|
|
542
543
|
}
|
|
543
544
|
return new constructor(stream);
|
|
544
545
|
});
|
|
@@ -551,13 +552,13 @@ function createMicrophoneStream(constructor, constraints) {
|
|
|
551
552
|
* @returns A Promise that resolves to a LocalDisplayStream or an error.
|
|
552
553
|
*/
|
|
553
554
|
function createDisplayStream(constructor, videoContentHint) {
|
|
554
|
-
return __awaiter$
|
|
555
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
555
556
|
let stream;
|
|
556
557
|
try {
|
|
557
558
|
stream = yield getDisplayMedia({ video: true });
|
|
558
559
|
}
|
|
559
560
|
catch (error) {
|
|
560
|
-
throw new
|
|
561
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create display stream: ${error}`);
|
|
561
562
|
}
|
|
562
563
|
const localDisplayStream = new constructor(stream);
|
|
563
564
|
if (videoContentHint) {
|
|
@@ -577,13 +578,13 @@ function createDisplayStream(constructor, videoContentHint) {
|
|
|
577
578
|
* instead.
|
|
578
579
|
*/
|
|
579
580
|
function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStreamConstructor, videoContentHint) {
|
|
580
|
-
return __awaiter$
|
|
581
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
581
582
|
let stream;
|
|
582
583
|
try {
|
|
583
584
|
stream = yield getDisplayMedia({ video: true, audio: true });
|
|
584
585
|
}
|
|
585
586
|
catch (error) {
|
|
586
|
-
throw new
|
|
587
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.CREATE_STREAM_FAILED, `Failed to create display and system audio streams: ${error}`);
|
|
587
588
|
}
|
|
588
589
|
// eslint-disable-next-line new-cap
|
|
589
590
|
const localDisplayStream = new displayStreamConstructor(new MediaStream(stream.getVideoTracks()));
|
|
@@ -605,13 +606,13 @@ function createDisplayStreamWithAudio(displayStreamConstructor, systemAudioStrea
|
|
|
605
606
|
* @returns List of media devices in an array of MediaDeviceInfo objects.
|
|
606
607
|
*/
|
|
607
608
|
function getDevices(deviceKind) {
|
|
608
|
-
return __awaiter$
|
|
609
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
609
610
|
let devices;
|
|
610
611
|
try {
|
|
611
612
|
devices = yield ensureDevicePermissions([DeviceKind.AudioInput, DeviceKind.VideoInput], enumerateDevices);
|
|
612
613
|
}
|
|
613
614
|
catch (error) {
|
|
614
|
-
throw new
|
|
615
|
+
throw new WebrtcCoreError(WebrtcCoreErrorType.DEVICE_PERMISSION_DENIED, 'Failed to ensure device permissions');
|
|
615
616
|
}
|
|
616
617
|
return devices.filter((v) => (deviceKind ? v.kind === deviceKind : true));
|
|
617
618
|
});
|
|
@@ -622,7 +623,7 @@ function getDevices(deviceKind) {
|
|
|
622
623
|
* @returns List of microphone devices in an array of MediaDeviceInfo objects.
|
|
623
624
|
*/
|
|
624
625
|
function getAudioInputDevices() {
|
|
625
|
-
return __awaiter$
|
|
626
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
626
627
|
return getDevices(DeviceKind.AudioInput);
|
|
627
628
|
});
|
|
628
629
|
}
|
|
@@ -632,7 +633,7 @@ function getAudioInputDevices() {
|
|
|
632
633
|
* @returns List of speaker devices in an array of MediaDeviceInfo objects.
|
|
633
634
|
*/
|
|
634
635
|
function getAudioOutputDevices() {
|
|
635
|
-
return __awaiter$
|
|
636
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
636
637
|
return getDevices(DeviceKind.AudioOutput);
|
|
637
638
|
});
|
|
638
639
|
}
|
|
@@ -642,7 +643,7 @@ function getAudioOutputDevices() {
|
|
|
642
643
|
* @returns List of camera devices in an array of MediaDeviceInfo objects.
|
|
643
644
|
*/
|
|
644
645
|
function getVideoInputDevices() {
|
|
645
|
-
return __awaiter$
|
|
646
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
646
647
|
return getDevices(DeviceKind.VideoInput);
|
|
647
648
|
});
|
|
648
649
|
}
|
|
@@ -1359,7 +1360,7 @@ class _LocalStream extends Stream {
|
|
|
1359
1360
|
* @param effect - The effect to add.
|
|
1360
1361
|
*/
|
|
1361
1362
|
addEffect(name, effect) {
|
|
1362
|
-
return __awaiter$
|
|
1363
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
1363
1364
|
// Load the effect
|
|
1364
1365
|
this.loadingEffects.set(name, effect);
|
|
1365
1366
|
const outputTrack = yield effect.load(this.outputTrack);
|
|
@@ -1410,7 +1411,7 @@ class _LocalStream extends Stream {
|
|
|
1410
1411
|
* Cleanup the local effects.
|
|
1411
1412
|
*/
|
|
1412
1413
|
disposeEffects() {
|
|
1413
|
-
return __awaiter$
|
|
1414
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
1414
1415
|
this.loadingEffects.clear();
|
|
1415
1416
|
// Dispose of any effects currently in use
|
|
1416
1417
|
if (this.effects.length > 0) {
|
|
@@ -1435,7 +1436,7 @@ class LocalAudioStream extends LocalStream {
|
|
|
1435
1436
|
* @returns A promise which resolves when the constraints have been successfully applied.
|
|
1436
1437
|
*/
|
|
1437
1438
|
applyConstraints(constraints) {
|
|
1438
|
-
return __awaiter$
|
|
1439
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
1439
1440
|
logger$3.log(`Applying constraints to local track:`, constraints);
|
|
1440
1441
|
return this.inputTrack.applyConstraints(constraints).then(() => {
|
|
1441
1442
|
this[LocalStreamEventNames.ConstraintsChange].emit();
|
|
@@ -1455,7 +1456,7 @@ class LocalVideoStream extends LocalStream {
|
|
|
1455
1456
|
* @returns A promise which resolves when the constraints have been successfully applied.
|
|
1456
1457
|
*/
|
|
1457
1458
|
applyConstraints(constraints) {
|
|
1458
|
-
return __awaiter$
|
|
1459
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
1459
1460
|
logger$3.log(`Applying constraints to local track:`, constraints);
|
|
1460
1461
|
return this.inputTrack.applyConstraints(constraints).then(() => {
|
|
1461
1462
|
this[LocalStreamEventNames.ConstraintsChange].emit();
|
|
@@ -5710,7 +5711,7 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5710
5711
|
* other peer.
|
|
5711
5712
|
*/
|
|
5712
5713
|
createAnswer(options) {
|
|
5713
|
-
return __awaiter$
|
|
5714
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5714
5715
|
return this.pc.createAnswer(options);
|
|
5715
5716
|
});
|
|
5716
5717
|
}
|
|
@@ -5725,7 +5726,7 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5725
5726
|
* That received offer should be delivered through the signaling server to a remote peer.
|
|
5726
5727
|
*/
|
|
5727
5728
|
createOffer(options) {
|
|
5728
|
-
return __awaiter$
|
|
5729
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5729
5730
|
return this.pc.createOffer(options);
|
|
5730
5731
|
});
|
|
5731
5732
|
}
|
|
@@ -5739,14 +5740,14 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5739
5740
|
*/
|
|
5740
5741
|
setLocalDescription(description) {
|
|
5741
5742
|
var _a;
|
|
5742
|
-
return __awaiter$
|
|
5743
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5743
5744
|
// In Firefox, setLocalDescription will not throw an error if an m-line has no codecs, even
|
|
5744
5745
|
// though it violates https://datatracker.ietf.org/doc/html/rfc8866. See
|
|
5745
5746
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1857612. So, we check the media lines here to
|
|
5746
5747
|
// preemptively throw an error on Firefox.
|
|
5747
5748
|
if (BrowserInfo$1.isFirefox()) {
|
|
5748
5749
|
(_a = description === null || description === void 0 ? void 0 : description.sdp) === null || _a === void 0 ? void 0 : _a.split(/(\r\n|\r|\n)/).filter((line) => line.startsWith('m')).forEach((mediaLine) => {
|
|
5749
|
-
if (mediaLine.split(' ').length < 4) {
|
|
5750
|
+
if (mediaLine.trim().split(' ').length < 4) {
|
|
5750
5751
|
throw new Error(`Invalid media line ${mediaLine}, expected at least 4 fields`);
|
|
5751
5752
|
}
|
|
5752
5753
|
});
|
|
@@ -5764,7 +5765,7 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5764
5765
|
* specified description is incompatible with one or both of the peers on the connection).
|
|
5765
5766
|
*/
|
|
5766
5767
|
setRemoteDescription(description) {
|
|
5767
|
-
return __awaiter$
|
|
5768
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5768
5769
|
return this.pc.setRemoteDescription(description);
|
|
5769
5770
|
});
|
|
5770
5771
|
}
|
|
@@ -5838,7 +5839,7 @@ class PeerConnection extends EventEmitter$4 {
|
|
|
5838
5839
|
*/
|
|
5839
5840
|
getCurrentConnectionType() {
|
|
5840
5841
|
var _a;
|
|
5841
|
-
return __awaiter$
|
|
5842
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
5842
5843
|
// make sure this method only can be called when the ice connection is established;
|
|
5843
5844
|
const isIceConnected = this.pc.iceConnectionState === 'connected' || this.pc.iceConnectionState === 'completed';
|
|
5844
5845
|
if (!isIceConnected) {
|
|
@@ -6862,1953 +6863,24 @@ class JmpSession extends EventEmitter$5 {
|
|
|
6862
6863
|
}
|
|
6863
6864
|
}
|
|
6864
6865
|
|
|
6865
|
-
var
|
|
6866
|
-
(function (MediaCodecMimeType) {
|
|
6867
|
-
MediaCodecMimeType["H264"] = "video/H264";
|
|
6868
|
-
MediaCodecMimeType["AV1"] = "video/AV1";
|
|
6869
|
-
MediaCodecMimeType["OPUS"] = "audio/opus";
|
|
6870
|
-
})(MediaCodecMimeType || (MediaCodecMimeType = {}));
|
|
6871
|
-
const defaultMaxVideoEncodeFrameSize = 8160;
|
|
6872
|
-
const defaultMaxVideoEncodeMbps = 244800;
|
|
6873
|
-
var RecommendedOpusBitrates;
|
|
6874
|
-
(function (RecommendedOpusBitrates) {
|
|
6875
|
-
RecommendedOpusBitrates[RecommendedOpusBitrates["NB"] = 12000] = "NB";
|
|
6876
|
-
RecommendedOpusBitrates[RecommendedOpusBitrates["WB"] = 20000] = "WB";
|
|
6877
|
-
RecommendedOpusBitrates[RecommendedOpusBitrates["FB"] = 40000] = "FB";
|
|
6878
|
-
RecommendedOpusBitrates[RecommendedOpusBitrates["FB_MONO_MUSIC"] = 64000] = "FB_MONO_MUSIC";
|
|
6879
|
-
RecommendedOpusBitrates[RecommendedOpusBitrates["FB_STEREO_MUSIC"] = 128000] = "FB_STEREO_MUSIC";
|
|
6880
|
-
})(RecommendedOpusBitrates || (RecommendedOpusBitrates = {}));
|
|
6881
|
-
const maxFrameSizeToMaxBitrateMap = new Map([
|
|
6882
|
-
[60, 99000],
|
|
6883
|
-
[240, 199000],
|
|
6884
|
-
[576, 300000],
|
|
6885
|
-
[920, 640000],
|
|
6886
|
-
[1296, 720000],
|
|
6887
|
-
[2304, 880000],
|
|
6888
|
-
[3600, 2500000],
|
|
6889
|
-
[8160, 4000000],
|
|
6890
|
-
]);
|
|
6891
|
-
function areProfileLevelIdsCompatible(senderProfileLevelId, receiverProfileLevelId, levelAsymmetryAllowed) {
|
|
6892
|
-
const senderProfile = Number.parseInt(`0x${senderProfileLevelId}`, 16);
|
|
6893
|
-
const recvProfile = Number.parseInt(`0x${receiverProfileLevelId}`, 16);
|
|
6894
|
-
const senderProfileIdc = senderProfile >> 16;
|
|
6895
|
-
const recvProfileIdc = recvProfile >> 16;
|
|
6896
|
-
const senderProfileIop = (senderProfile & 0x00ff00) >> 8;
|
|
6897
|
-
const recvProfileIop = (recvProfile & 0x00ff00) >> 8;
|
|
6898
|
-
const senderLevelIdc = senderProfile & 0x0000ff;
|
|
6899
|
-
const recvLevelIdc = recvProfile & 0x0000ff;
|
|
6900
|
-
const areProfileCompatible = (senderProfileIdc === recvProfileIdc && senderProfileIop === recvProfileIop) ||
|
|
6901
|
-
(senderProfileIdc === 0x42 &&
|
|
6902
|
-
recvProfileIdc === 0x42 &&
|
|
6903
|
-
(senderProfileIop & 0x40) === (recvProfileIop & 0x40));
|
|
6904
|
-
const isLevelIdcCompatible = levelAsymmetryAllowed
|
|
6905
|
-
? true
|
|
6906
|
-
: senderLevelIdc <= recvLevelIdc;
|
|
6907
|
-
return areProfileCompatible && isLevelIdcCompatible;
|
|
6908
|
-
}
|
|
6909
|
-
function areCodecsCompatible(senderCodec, receiverCodec) {
|
|
6910
|
-
return Object.keys(receiverCodec).every((key) => {
|
|
6911
|
-
if (key === 'clockRate' || key === 'name') {
|
|
6912
|
-
return senderCodec[key] === receiverCodec[key];
|
|
6913
|
-
}
|
|
6914
|
-
if (key === 'fmtParams') {
|
|
6915
|
-
const fmtpForSender = senderCodec[key];
|
|
6916
|
-
const fmtpForReceiver = receiverCodec[key];
|
|
6917
|
-
const levelAsymmetryAllowed = [...fmtpForSender.keys()].some((senderFmtpParamKey) => {
|
|
6918
|
-
return (senderFmtpParamKey === 'level-asymmetry-allowed' &&
|
|
6919
|
-
fmtpForReceiver.get(senderFmtpParamKey) === '1' &&
|
|
6920
|
-
fmtpForSender.get(senderFmtpParamKey) === '1');
|
|
6921
|
-
});
|
|
6922
|
-
return [...fmtpForSender.keys()].every((senderFmtpParamKey) => {
|
|
6923
|
-
if (fmtpForReceiver.get(senderFmtpParamKey)) {
|
|
6924
|
-
if (senderFmtpParamKey === 'profile-level-id') {
|
|
6925
|
-
return areProfileLevelIdsCompatible(fmtpForSender.get(senderFmtpParamKey), fmtpForReceiver.get(senderFmtpParamKey), levelAsymmetryAllowed);
|
|
6926
|
-
}
|
|
6927
|
-
}
|
|
6928
|
-
if (senderFmtpParamKey === 'packetization-mode') {
|
|
6929
|
-
return fmtpForSender.get(senderFmtpParamKey) === fmtpForReceiver.get(senderFmtpParamKey);
|
|
6930
|
-
}
|
|
6931
|
-
return true;
|
|
6932
|
-
});
|
|
6933
|
-
}
|
|
6934
|
-
return true;
|
|
6935
|
-
});
|
|
6936
|
-
}
|
|
6937
|
-
function gcd(a, b) {
|
|
6938
|
-
return b === 0 ? a : gcd(b, a % b);
|
|
6939
|
-
}
|
|
6940
|
-
function getFrameHeightByMaxFs(sourceAspectRatio, requestedMaxFs) {
|
|
6941
|
-
const _gcd = gcd(sourceAspectRatio[0], sourceAspectRatio[1]);
|
|
6942
|
-
const minNumberRatiosForWidth = sourceAspectRatio[0] / _gcd;
|
|
6943
|
-
const minNumberRatiosForHeight = sourceAspectRatio[1] / _gcd;
|
|
6944
|
-
return (Math.floor(Math.sqrt((requestedMaxFs * 16 * 16) / (minNumberRatiosForWidth * minNumberRatiosForHeight))) * minNumberRatiosForHeight);
|
|
6945
|
-
}
|
|
6946
|
-
function getScaleDownRatio(sourceWidth, sourceHeight, maxFs, maxWidth, maxHeight) {
|
|
6947
|
-
if (!sourceWidth || !sourceHeight || !maxFs) {
|
|
6948
|
-
return undefined;
|
|
6949
|
-
}
|
|
6950
|
-
let scaleDownRatio = Math.max(sourceHeight / getFrameHeightByMaxFs([sourceWidth, sourceHeight], maxFs), 1.0);
|
|
6951
|
-
if (maxWidth && maxHeight) {
|
|
6952
|
-
scaleDownRatio = Math.max(sourceWidth / maxWidth, sourceHeight / maxHeight, scaleDownRatio);
|
|
6953
|
-
}
|
|
6954
|
-
return scaleDownRatio;
|
|
6955
|
-
}
|
|
6956
|
-
function getRecommendedMaxBitrateForFrameSize(requestedMaxFs) {
|
|
6957
|
-
if (requestedMaxFs < 60) {
|
|
6958
|
-
throw new Error(`requested video max frame size can not less than 60`);
|
|
6959
|
-
}
|
|
6960
|
-
const expectedHeight = [...maxFrameSizeToMaxBitrateMap.keys()]
|
|
6961
|
-
.sort((a, b) => b - a)
|
|
6962
|
-
.find((h) => requestedMaxFs >= h);
|
|
6963
|
-
return maxFrameSizeToMaxBitrateMap.get(expectedHeight);
|
|
6964
|
-
}
|
|
6866
|
+
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6965
6867
|
|
|
6966
|
-
|
|
6967
|
-
|
|
6868
|
+
var logger$1 = {exports: {}};
|
|
6869
|
+
|
|
6870
|
+
/*!
|
|
6871
|
+
* js-logger - http://github.com/jonnyreeves/js-logger
|
|
6872
|
+
* Jonny Reeves, http://jonnyreeves.co.uk/
|
|
6873
|
+
* js-logger may be freely distributed under the MIT license.
|
|
6874
|
+
*/
|
|
6875
|
+
|
|
6876
|
+
(function (module) {
|
|
6877
|
+
(function (global) {
|
|
6968
6878
|
|
|
6969
|
-
|
|
6970
|
-
|
|
6879
|
+
// Top level module for the global, static logger instance.
|
|
6880
|
+
var Logger = { };
|
|
6971
6881
|
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
6975
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
6976
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
6977
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
6978
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
6979
|
-
***************************************************************************** */
|
|
6980
|
-
|
|
6981
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
6982
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6983
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6984
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6985
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6986
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
6987
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6988
|
-
});
|
|
6989
|
-
}
|
|
6990
|
-
|
|
6991
|
-
var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6992
|
-
|
|
6993
|
-
var rtcStats_1 = void 0;
|
|
6994
|
-
/**
|
|
6995
|
-
* Copies values of any nested depth.
|
|
6996
|
-
*
|
|
6997
|
-
* @param value - The value to be copied.
|
|
6998
|
-
* @returns - Copied value.
|
|
6999
|
-
*/
|
|
7000
|
-
var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
|
|
7001
|
-
/**
|
|
7002
|
-
* Check deep equality between two values.
|
|
7003
|
-
*
|
|
7004
|
-
* @param value1 - First value to check.
|
|
7005
|
-
* @param value2 - Second value to check.
|
|
7006
|
-
* @returns True if values are deeply equal, false otherwise.
|
|
7007
|
-
*/
|
|
7008
|
-
var deepEqual = function (value1, value2) {
|
|
7009
|
-
// If both immutable values are equal, return true.
|
|
7010
|
-
if (value1 === value2) {
|
|
7011
|
-
return true;
|
|
7012
|
-
}
|
|
7013
|
-
// If both are objects, we check the length and properties of each.
|
|
7014
|
-
if (value1 && value2 && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
7015
|
-
if (value1.constructor !== value2.constructor)
|
|
7016
|
-
return false;
|
|
7017
|
-
// Return false if the objects are of different sizes.
|
|
7018
|
-
if (Object.keys(value1).length !== Object.keys(value2).length) {
|
|
7019
|
-
return false;
|
|
7020
|
-
}
|
|
7021
|
-
// Deep equal check each property in the object, returns true if we found no
|
|
7022
|
-
// differing properties.
|
|
7023
|
-
return Object.keys(value1).reduce(function (val, prop) {
|
|
7024
|
-
if (value2[prop]) {
|
|
7025
|
-
if (!deepEqual(value1[prop], value2[prop])) {
|
|
7026
|
-
return false;
|
|
7027
|
-
}
|
|
7028
|
-
}
|
|
7029
|
-
else {
|
|
7030
|
-
return false;
|
|
7031
|
-
}
|
|
7032
|
-
return val;
|
|
7033
|
-
}, true);
|
|
7034
|
-
}
|
|
7035
|
-
// Return false if no other conditions are met.
|
|
7036
|
-
return false;
|
|
7037
|
-
};
|
|
7038
|
-
/**
|
|
7039
|
-
* Translates a Map into an object.
|
|
7040
|
-
*
|
|
7041
|
-
* @param report - The report in Map form.
|
|
7042
|
-
* @returns - A deduped object.
|
|
7043
|
-
*/
|
|
7044
|
-
var map2obj = function (report) {
|
|
7045
|
-
if (!report.size) {
|
|
7046
|
-
return report;
|
|
7047
|
-
}
|
|
7048
|
-
var o = {};
|
|
7049
|
-
report.forEach(function (value, key) {
|
|
7050
|
-
o[key] = value;
|
|
7051
|
-
});
|
|
7052
|
-
return o;
|
|
7053
|
-
};
|
|
7054
|
-
var dumpStream = function (stream) { return ({
|
|
7055
|
-
id: stream.id,
|
|
7056
|
-
tracks: stream.getTracks().map(function (track) { return ({
|
|
7057
|
-
id: track.id,
|
|
7058
|
-
kind: track.kind,
|
|
7059
|
-
label: track.label,
|
|
7060
|
-
enabled: track.enabled,
|
|
7061
|
-
muted: track.muted,
|
|
7062
|
-
readyState: track.readyState
|
|
7063
|
-
}); })
|
|
7064
|
-
}); };
|
|
7065
|
-
var persistedKeys = ['type', 'id', 'timestamp'];
|
|
7066
|
-
/**
|
|
7067
|
-
* Check to see if the report consists of more than just the persisted metadata.
|
|
7068
|
-
*
|
|
7069
|
-
* @param report - The report line being checked.
|
|
7070
|
-
* @returns True if the report item contains non-persisted keys, false otherwise.
|
|
7071
|
-
*/
|
|
7072
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7073
|
-
var hasNonMetadata = function (report) {
|
|
7074
|
-
return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
|
|
7075
|
-
};
|
|
7076
|
-
/**
|
|
7077
|
-
* Apply a delta compression to the stats report. Reduces size by ~90%.
|
|
7078
|
-
* To reduce further, report keys could be compressed.
|
|
7079
|
-
*
|
|
7080
|
-
* @param oldStats - Previous report items that we dedupe against.
|
|
7081
|
-
* @param newStats - New incoming stats.
|
|
7082
|
-
* @returns - Compressed Stats.
|
|
7083
|
-
*/
|
|
7084
|
-
var deltaCompression = function (oldStats, newStats) {
|
|
7085
|
-
var updatedStats = deepCopy$1(newStats);
|
|
7086
|
-
Object.keys(updatedStats).forEach(function (id) {
|
|
7087
|
-
var report = updatedStats[id];
|
|
7088
|
-
if (!oldStats[id]) {
|
|
7089
|
-
return;
|
|
7090
|
-
}
|
|
7091
|
-
// Persist specific values beyond delta compression, as long as they
|
|
7092
|
-
// aren't the only non-deduped keys.
|
|
7093
|
-
Object.keys(report).forEach(function (name) {
|
|
7094
|
-
if (deepEqual(report[name], oldStats[id][name]) && !persistedKeys.includes(name)) {
|
|
7095
|
-
delete updatedStats[id][name];
|
|
7096
|
-
}
|
|
7097
|
-
if (!hasNonMetadata(report)) {
|
|
7098
|
-
delete updatedStats[id];
|
|
7099
|
-
}
|
|
7100
|
-
});
|
|
7101
|
-
});
|
|
7102
|
-
// Use the most recent timestamp.
|
|
7103
|
-
var timestamp = -Infinity;
|
|
7104
|
-
Object.keys(updatedStats).forEach(function (id) {
|
|
7105
|
-
var report = updatedStats[id];
|
|
7106
|
-
if (report.timestamp > timestamp) {
|
|
7107
|
-
timestamp = report.timestamp;
|
|
7108
|
-
}
|
|
7109
|
-
});
|
|
7110
|
-
// Delete the timestamps on each item.
|
|
7111
|
-
Object.keys(updatedStats).forEach(function (id) {
|
|
7112
|
-
var report = updatedStats[id];
|
|
7113
|
-
if (report.timestamp === timestamp) {
|
|
7114
|
-
delete report.timestamp;
|
|
7115
|
-
}
|
|
7116
|
-
});
|
|
7117
|
-
updatedStats.timestamp = timestamp;
|
|
7118
|
-
return updatedStats;
|
|
7119
|
-
};
|
|
7120
|
-
/**
|
|
7121
|
-
* Format the stats report into an array.
|
|
7122
|
-
*
|
|
7123
|
-
* @param report - A WebRTC stats report.
|
|
7124
|
-
* @returns - An array of Stats Report items.
|
|
7125
|
-
*/
|
|
7126
|
-
var formatStatsReport = function (report) {
|
|
7127
|
-
return Object.keys(report)
|
|
7128
|
-
.filter(function (name) { return name !== 'timestamp'; })
|
|
7129
|
-
.map(function (name) { return JSON.stringify(report[name]); });
|
|
7130
|
-
};
|
|
7131
|
-
/**
|
|
7132
|
-
* Parametrize a single string event to contain type and an (empty) id.
|
|
7133
|
-
*
|
|
7134
|
-
* @param value - The value to parametrize.
|
|
7135
|
-
* @returns An event object.
|
|
7136
|
-
*/
|
|
7137
|
-
var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
|
|
7138
|
-
/**
|
|
7139
|
-
* Attach a Peer Connection to periodically get updated on events and stats.
|
|
7140
|
-
*
|
|
7141
|
-
* @param pc - Peer Connection in which we attach.
|
|
7142
|
-
* @param logger - Logging function to log events and stats.
|
|
7143
|
-
* @param intervalTime - Time between each `getStats` check.
|
|
7144
|
-
* @param statsPreProcessor - Optional function that modifies stats.
|
|
7145
|
-
*/
|
|
7146
|
-
var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
|
|
7147
|
-
if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
|
|
7148
|
-
var prev = {};
|
|
7149
|
-
/**
|
|
7150
|
-
* Log stats or event data with additional tracking information.
|
|
7151
|
-
*
|
|
7152
|
-
* @param name - Name of the event to log.
|
|
7153
|
-
* @param payload - Log data pertaining to the event.
|
|
7154
|
-
* @param timestamp - Time the event happened in milliseconds.
|
|
7155
|
-
*/
|
|
7156
|
-
var trace = function (name, payload, timestamp) {
|
|
7157
|
-
logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
|
|
7158
|
-
};
|
|
7159
|
-
var origPeerConnection = window.RTCPeerConnection;
|
|
7160
|
-
pc.addEventListener('icecandidate', function (e) {
|
|
7161
|
-
if (e.candidate) {
|
|
7162
|
-
trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
|
|
7163
|
-
}
|
|
7164
|
-
});
|
|
7165
|
-
pc.addEventListener('icecandidateerror', function (event) {
|
|
7166
|
-
var _a = event, errorCode = _a.errorCode, errorText = _a.errorText;
|
|
7167
|
-
trace('onicecandidateerror', makeEvent("".concat(errorCode, ": ").concat(errorText)));
|
|
7168
|
-
});
|
|
7169
|
-
pc.addEventListener('track', function (e) {
|
|
7170
|
-
trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
|
|
7171
|
-
.map(function (stream) { return "stream:".concat(stream.id); })
|
|
7172
|
-
.join(' '))));
|
|
7173
|
-
});
|
|
7174
|
-
pc.addEventListener('signalingstatechange', function () {
|
|
7175
|
-
trace('onsignalingstatechange', makeEvent(pc.signalingState));
|
|
7176
|
-
});
|
|
7177
|
-
pc.addEventListener('iceconnectionstatechange', function () {
|
|
7178
|
-
trace('oniceconnectionstatechange', makeEvent(pc.iceConnectionState));
|
|
7179
|
-
});
|
|
7180
|
-
pc.addEventListener('icegatheringstatechange', function () {
|
|
7181
|
-
trace('onicegatheringstatechange', makeEvent(pc.iceGatheringState));
|
|
7182
|
-
});
|
|
7183
|
-
pc.addEventListener('connectionstatechange', function () {
|
|
7184
|
-
trace('onconnectionstatechange', makeEvent(pc.connectionState));
|
|
7185
|
-
});
|
|
7186
|
-
pc.addEventListener('negotiationneeded', function () {
|
|
7187
|
-
trace('onnegotiationneeded', makeEvent('negotiationneeded'));
|
|
7188
|
-
});
|
|
7189
|
-
pc.addEventListener('datachannel', function (event) {
|
|
7190
|
-
trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
|
|
7191
|
-
});
|
|
7192
|
-
['createDataChannel', 'close'].forEach(function (method) {
|
|
7193
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7194
|
-
if (nativeMethod) {
|
|
7195
|
-
origPeerConnection.prototype[method] = function () {
|
|
7196
|
-
trace(method, makeEvent(method));
|
|
7197
|
-
return nativeMethod.apply(this, arguments);
|
|
7198
|
-
};
|
|
7199
|
-
}
|
|
7200
|
-
});
|
|
7201
|
-
['addStream', 'removeStream'].forEach(function (method) {
|
|
7202
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7203
|
-
if (nativeMethod) {
|
|
7204
|
-
origPeerConnection.prototype[method] = function () {
|
|
7205
|
-
var stream = arguments[0];
|
|
7206
|
-
var streamInfo = stream
|
|
7207
|
-
.getTracks()
|
|
7208
|
-
.map(function (t) { return "".concat(t.kind, ":").concat(t.id); })
|
|
7209
|
-
.join(',');
|
|
7210
|
-
trace(method, makeEvent("".concat(stream.id, " ").concat(streamInfo)));
|
|
7211
|
-
return nativeMethod.apply(this, arguments);
|
|
7212
|
-
};
|
|
7213
|
-
}
|
|
7214
|
-
});
|
|
7215
|
-
['addTrack'].forEach(function (method) {
|
|
7216
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7217
|
-
if (nativeMethod) {
|
|
7218
|
-
origPeerConnection.prototype[method] = function () {
|
|
7219
|
-
var track = arguments[0];
|
|
7220
|
-
var streams = [].slice.call(arguments, 1);
|
|
7221
|
-
trace(method, makeEvent("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) { return "stream:".concat(s.id); }).join(';') || '-')));
|
|
7222
|
-
return nativeMethod.apply(this, arguments);
|
|
7223
|
-
};
|
|
7224
|
-
}
|
|
7225
|
-
});
|
|
7226
|
-
['removeTrack'].forEach(function (method) {
|
|
7227
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7228
|
-
if (nativeMethod) {
|
|
7229
|
-
origPeerConnection.prototype[method] = function () {
|
|
7230
|
-
var track = arguments[0].track;
|
|
7231
|
-
trace(method, makeEvent(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
|
|
7232
|
-
return nativeMethod.apply(this, arguments);
|
|
7233
|
-
};
|
|
7234
|
-
}
|
|
7235
|
-
});
|
|
7236
|
-
['createOffer', 'createAnswer'].forEach(function (method) {
|
|
7237
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7238
|
-
if (nativeMethod) {
|
|
7239
|
-
origPeerConnection.prototype[method] = function () {
|
|
7240
|
-
var opts;
|
|
7241
|
-
var args = arguments;
|
|
7242
|
-
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
|
7243
|
-
// eslint-disable-next-line prefer-destructuring
|
|
7244
|
-
opts = arguments[0];
|
|
7245
|
-
}
|
|
7246
|
-
else if (arguments.length === 3 && typeof arguments[2] === 'object') {
|
|
7247
|
-
// eslint-disable-next-line prefer-destructuring
|
|
7248
|
-
opts = arguments[2];
|
|
7249
|
-
}
|
|
7250
|
-
trace(method, makeEvent(opts || ''));
|
|
7251
|
-
return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
|
|
7252
|
-
trace("".concat(method, "OnSuccess"), makeEvent(description.sdp));
|
|
7253
|
-
if (args.length > 0 && typeof args[0] === 'function') {
|
|
7254
|
-
args[0].apply(null, [description]);
|
|
7255
|
-
return undefined;
|
|
7256
|
-
}
|
|
7257
|
-
return description;
|
|
7258
|
-
}, function (err) {
|
|
7259
|
-
trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
|
|
7260
|
-
if (args.length > 1 && typeof args[1] === 'function') {
|
|
7261
|
-
args[1].apply(null, [err]);
|
|
7262
|
-
return;
|
|
7263
|
-
}
|
|
7264
|
-
throw err;
|
|
7265
|
-
});
|
|
7266
|
-
};
|
|
7267
|
-
}
|
|
7268
|
-
});
|
|
7269
|
-
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
|
|
7270
|
-
var nativeMethod = origPeerConnection.prototype[method];
|
|
7271
|
-
if (nativeMethod) {
|
|
7272
|
-
origPeerConnection.prototype[method] = function () {
|
|
7273
|
-
var args = arguments;
|
|
7274
|
-
trace(method, makeEvent(method === 'addIceCandidate' ? arguments[0] : arguments[0].sdp));
|
|
7275
|
-
return nativeMethod.apply(this, [arguments[0]]).then(function () {
|
|
7276
|
-
trace("".concat(method, "OnSuccess"), makeEvent('success'));
|
|
7277
|
-
if (args.length >= 2 && typeof args[1] === 'function') {
|
|
7278
|
-
args[1].apply(null, []);
|
|
7279
|
-
return undefined;
|
|
7280
|
-
}
|
|
7281
|
-
return undefined;
|
|
7282
|
-
}, function (err) {
|
|
7283
|
-
trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
|
|
7284
|
-
if (args.length >= 3 && typeof args[2] === 'function') {
|
|
7285
|
-
args[2].apply(null, [err]);
|
|
7286
|
-
return undefined;
|
|
7287
|
-
}
|
|
7288
|
-
throw err;
|
|
7289
|
-
});
|
|
7290
|
-
};
|
|
7291
|
-
}
|
|
7292
|
-
});
|
|
7293
|
-
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
7294
|
-
var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
7295
|
-
var gum = function () {
|
|
7296
|
-
trace('navigator.mediaDevices.getUserMedia', makeEvent(JSON.stringify(arguments[0])));
|
|
7297
|
-
return origGetUserMedia_1
|
|
7298
|
-
.apply(navigator.mediaDevices, arguments)
|
|
7299
|
-
.then(function (stream) {
|
|
7300
|
-
trace('navigator.mediaDevices.getUserMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
|
|
7301
|
-
return stream;
|
|
7302
|
-
}, function (err) {
|
|
7303
|
-
trace('navigator.mediaDevices.getUserMediaOnFailure', makeEvent(err.name));
|
|
7304
|
-
return Promise.reject(err);
|
|
7305
|
-
});
|
|
7306
|
-
};
|
|
7307
|
-
navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
|
|
7308
|
-
}
|
|
7309
|
-
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
7310
|
-
var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
|
|
7311
|
-
var gdm = function () {
|
|
7312
|
-
trace('navigator.mediaDevices.getDisplayMedia', makeEvent(JSON.stringify(arguments[0])));
|
|
7313
|
-
return origGetDisplayMedia_1
|
|
7314
|
-
.apply(navigator.mediaDevices, arguments)
|
|
7315
|
-
.then(function (stream) {
|
|
7316
|
-
trace('navigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
|
|
7317
|
-
return stream;
|
|
7318
|
-
}, function (err) {
|
|
7319
|
-
trace('navigator.mediaDevices.getDisplayMediaOnFailure', makeEvent(err.name));
|
|
7320
|
-
return Promise.reject(err);
|
|
7321
|
-
});
|
|
7322
|
-
};
|
|
7323
|
-
navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
|
|
7324
|
-
}
|
|
7325
|
-
var interval = window.setInterval(function () {
|
|
7326
|
-
if (pc.signalingState === 'closed') {
|
|
7327
|
-
window.clearInterval(interval);
|
|
7328
|
-
return;
|
|
7329
|
-
}
|
|
7330
|
-
pc.getStats(null).then(function (res) {
|
|
7331
|
-
// Convert from stats report to js Map in order to have values set in `statsPreProcessor`
|
|
7332
|
-
var statsMap = new Map();
|
|
7333
|
-
res.forEach(function (stats, key) { return statsMap.set(key, stats); });
|
|
7334
|
-
statsPreProcessor(statsMap).then(function () {
|
|
7335
|
-
var now = map2obj(statsMap);
|
|
7336
|
-
var base = deepCopy$1(now); // our new prev
|
|
7337
|
-
var compressed = deltaCompression(prev, now);
|
|
7338
|
-
trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
|
|
7339
|
-
prev = base;
|
|
7340
|
-
});
|
|
7341
|
-
});
|
|
7342
|
-
}, intervalTime);
|
|
7343
|
-
};
|
|
7344
|
-
rtcStats_1 = rtcStats;
|
|
7345
|
-
|
|
7346
|
-
const NUM = '\\d+';
|
|
7347
|
-
const SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
|
|
7348
|
-
const ANY_NON_WS = '\\S+';
|
|
7349
|
-
const SP = '\\s';
|
|
7350
|
-
const REST = '.+';
|
|
7351
|
-
|
|
7352
|
-
class Line {
|
|
7353
|
-
}
|
|
7354
|
-
|
|
7355
|
-
var _a$5;
|
|
7356
|
-
class BandwidthLine extends Line {
|
|
7357
|
-
constructor(bandwidthType, bandwidth) {
|
|
7358
|
-
super();
|
|
7359
|
-
this.bandwidthType = bandwidthType;
|
|
7360
|
-
this.bandwidth = bandwidth;
|
|
7361
|
-
}
|
|
7362
|
-
static fromSdpLine(line) {
|
|
7363
|
-
if (!BandwidthLine.regex.test(line)) {
|
|
7364
|
-
return undefined;
|
|
7365
|
-
}
|
|
7366
|
-
const tokens = line.match(BandwidthLine.regex);
|
|
7367
|
-
const bandwidthType = tokens[1];
|
|
7368
|
-
const bandwidth = parseInt(tokens[2], 10);
|
|
7369
|
-
return new BandwidthLine(bandwidthType, bandwidth);
|
|
7370
|
-
}
|
|
7371
|
-
toSdpLine() {
|
|
7372
|
-
return `b=${this.bandwidthType}:${this.bandwidth}`;
|
|
7373
|
-
}
|
|
7374
|
-
}
|
|
7375
|
-
_a$5 = BandwidthLine;
|
|
7376
|
-
BandwidthLine.BW_TYPE_REGEX = 'CT|AS|TIAS';
|
|
7377
|
-
BandwidthLine.regex = new RegExp(`^(${_a$5.BW_TYPE_REGEX}):(${NUM})`);
|
|
7378
|
-
|
|
7379
|
-
class BundleGroupLine extends Line {
|
|
7380
|
-
constructor(mids) {
|
|
7381
|
-
super();
|
|
7382
|
-
this.mids = mids;
|
|
7383
|
-
}
|
|
7384
|
-
static fromSdpLine(line) {
|
|
7385
|
-
if (!BundleGroupLine.regex.test(line)) {
|
|
7386
|
-
return undefined;
|
|
7387
|
-
}
|
|
7388
|
-
const tokens = line.match(BundleGroupLine.regex);
|
|
7389
|
-
const mids = tokens[1].split(' ');
|
|
7390
|
-
return new BundleGroupLine(mids);
|
|
7391
|
-
}
|
|
7392
|
-
toSdpLine() {
|
|
7393
|
-
return `a=group:BUNDLE ${this.mids.join(' ')}`;
|
|
7394
|
-
}
|
|
7395
|
-
}
|
|
7396
|
-
BundleGroupLine.regex = new RegExp(`^group:BUNDLE (${REST})`);
|
|
7397
|
-
|
|
7398
|
-
var _a$4;
|
|
7399
|
-
class CandidateLine extends Line {
|
|
7400
|
-
constructor(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions) {
|
|
7401
|
-
super();
|
|
7402
|
-
this.foundation = foundation;
|
|
7403
|
-
this.componentId = componentId;
|
|
7404
|
-
this.transport = transport;
|
|
7405
|
-
this.priority = priority;
|
|
7406
|
-
this.connectionAddress = connectionAddress;
|
|
7407
|
-
this.port = port;
|
|
7408
|
-
this.candidateType = candidateType;
|
|
7409
|
-
this.relAddr = relAddr;
|
|
7410
|
-
this.relPort = relPort;
|
|
7411
|
-
this.candidateExtensions = candidateExtensions;
|
|
7412
|
-
}
|
|
7413
|
-
static fromSdpLine(line) {
|
|
7414
|
-
if (!CandidateLine.regex.test(line)) {
|
|
7415
|
-
return undefined;
|
|
7416
|
-
}
|
|
7417
|
-
const tokens = line.match(CandidateLine.regex);
|
|
7418
|
-
const foundation = tokens[1];
|
|
7419
|
-
const componentId = parseInt(tokens[2], 10);
|
|
7420
|
-
const transport = tokens[3];
|
|
7421
|
-
const priority = parseInt(tokens[4], 10);
|
|
7422
|
-
const connectionAddress = tokens[5];
|
|
7423
|
-
const port = parseInt(tokens[6], 10);
|
|
7424
|
-
const candidateType = tokens[7];
|
|
7425
|
-
const relAddr = tokens[8];
|
|
7426
|
-
const relPort = tokens[9] ? parseInt(tokens[9], 10) : undefined;
|
|
7427
|
-
const candidateExtensions = tokens[10];
|
|
7428
|
-
return new CandidateLine(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions);
|
|
7429
|
-
}
|
|
7430
|
-
toSdpLine() {
|
|
7431
|
-
let str = '';
|
|
7432
|
-
str += `a=candidate:${this.foundation} ${this.componentId} ${this.transport} ${this.priority} ${this.connectionAddress} ${this.port} typ ${this.candidateType}`;
|
|
7433
|
-
if (this.relAddr) {
|
|
7434
|
-
str += ` raddr ${this.relAddr}`;
|
|
7435
|
-
}
|
|
7436
|
-
if (this.relPort) {
|
|
7437
|
-
str += ` rport ${this.relPort}`;
|
|
7438
|
-
}
|
|
7439
|
-
if (this.candidateExtensions) {
|
|
7440
|
-
str += ` ${this.candidateExtensions}`;
|
|
7441
|
-
}
|
|
7442
|
-
return str;
|
|
7443
|
-
}
|
|
7444
|
-
}
|
|
7445
|
-
_a$4 = CandidateLine;
|
|
7446
|
-
CandidateLine.ICE_CHARS = `[a-zA-Z0-9+/]+`;
|
|
7447
|
-
CandidateLine.regex = new RegExp(`^candidate:(${_a$4.ICE_CHARS}) (${NUM}) (${ANY_NON_WS}) (${NUM}) (${ANY_NON_WS}) (${NUM}) typ (${ANY_NON_WS})(?: raddr (${ANY_NON_WS}))?(?: rport (${NUM}))?(?: (${REST}))?`);
|
|
7448
|
-
|
|
7449
|
-
class ConnectionLine extends Line {
|
|
7450
|
-
constructor(netType, addrType, ipAddr) {
|
|
7451
|
-
super();
|
|
7452
|
-
this.netType = netType;
|
|
7453
|
-
this.addrType = addrType;
|
|
7454
|
-
this.ipAddr = ipAddr;
|
|
7455
|
-
}
|
|
7456
|
-
static fromSdpLine(line) {
|
|
7457
|
-
if (!ConnectionLine.regex.test(line)) {
|
|
7458
|
-
return undefined;
|
|
7459
|
-
}
|
|
7460
|
-
const tokens = line.match(ConnectionLine.regex);
|
|
7461
|
-
const netType = tokens[1];
|
|
7462
|
-
const addrType = tokens[2];
|
|
7463
|
-
const ipAddr = tokens[3];
|
|
7464
|
-
return new ConnectionLine(netType, addrType, ipAddr);
|
|
7465
|
-
}
|
|
7466
|
-
toSdpLine() {
|
|
7467
|
-
return `c=${this.netType} ${this.addrType} ${this.ipAddr}`;
|
|
7468
|
-
}
|
|
7469
|
-
}
|
|
7470
|
-
ConnectionLine.regex = new RegExp(`^(${ANY_NON_WS}) (${ANY_NON_WS}) (${ANY_NON_WS})`);
|
|
7471
|
-
|
|
7472
|
-
class ContentLine extends Line {
|
|
7473
|
-
constructor(values) {
|
|
7474
|
-
super();
|
|
7475
|
-
this.values = values;
|
|
7476
|
-
}
|
|
7477
|
-
static fromSdpLine(line) {
|
|
7478
|
-
if (!ContentLine.regex.test(line)) {
|
|
7479
|
-
return undefined;
|
|
7480
|
-
}
|
|
7481
|
-
const tokens = line.match(ContentLine.regex);
|
|
7482
|
-
const values = tokens[1].split(',');
|
|
7483
|
-
return new ContentLine(values);
|
|
7484
|
-
}
|
|
7485
|
-
toSdpLine() {
|
|
7486
|
-
return `a=content:${this.values.join(',')}`;
|
|
7487
|
-
}
|
|
7488
|
-
}
|
|
7489
|
-
ContentLine.regex = new RegExp(`^content:(${REST})$`);
|
|
7490
|
-
|
|
7491
|
-
class DirectionLine extends Line {
|
|
7492
|
-
constructor(direction) {
|
|
7493
|
-
super();
|
|
7494
|
-
this.direction = direction;
|
|
7495
|
-
}
|
|
7496
|
-
static fromSdpLine(line) {
|
|
7497
|
-
if (!DirectionLine.regex.test(line)) {
|
|
7498
|
-
return undefined;
|
|
7499
|
-
}
|
|
7500
|
-
const tokens = line.match(DirectionLine.regex);
|
|
7501
|
-
const direction = tokens[1];
|
|
7502
|
-
return new DirectionLine(direction);
|
|
7503
|
-
}
|
|
7504
|
-
toSdpLine() {
|
|
7505
|
-
return `a=${this.direction}`;
|
|
7506
|
-
}
|
|
7507
|
-
}
|
|
7508
|
-
DirectionLine.regex = /^(sendrecv|sendonly|recvonly|inactive)$/;
|
|
7509
|
-
|
|
7510
|
-
var _a$3;
|
|
7511
|
-
class ExtMapLine extends Line {
|
|
7512
|
-
constructor(id, uri, direction, extensionAttributes) {
|
|
7513
|
-
super();
|
|
7514
|
-
this.id = id;
|
|
7515
|
-
this.uri = uri;
|
|
7516
|
-
this.direction = direction;
|
|
7517
|
-
this.extensionAttributes = extensionAttributes;
|
|
7518
|
-
}
|
|
7519
|
-
static fromSdpLine(line) {
|
|
7520
|
-
if (!ExtMapLine.regex.test(line)) {
|
|
7521
|
-
return undefined;
|
|
7522
|
-
}
|
|
7523
|
-
const tokens = line.match(ExtMapLine.regex);
|
|
7524
|
-
const id = parseInt(tokens[1], 10);
|
|
7525
|
-
const direction = tokens[2];
|
|
7526
|
-
const uri = tokens[3];
|
|
7527
|
-
const extensionAttributes = tokens[4];
|
|
7528
|
-
return new ExtMapLine(id, uri, direction, extensionAttributes);
|
|
7529
|
-
}
|
|
7530
|
-
toSdpLine() {
|
|
7531
|
-
let str = '';
|
|
7532
|
-
str += `a=extmap:${this.id}`;
|
|
7533
|
-
if (this.direction) {
|
|
7534
|
-
str += `/${this.direction}`;
|
|
7535
|
-
}
|
|
7536
|
-
str += ` ${this.uri}`;
|
|
7537
|
-
if (this.extensionAttributes) {
|
|
7538
|
-
str += ` ${this.extensionAttributes}`;
|
|
7539
|
-
}
|
|
7540
|
-
return str;
|
|
7541
|
-
}
|
|
7542
|
-
}
|
|
7543
|
-
_a$3 = ExtMapLine;
|
|
7544
|
-
ExtMapLine.EXTMAP_DIRECTION = `sendonly|recvonly|sendrecv|inactive`;
|
|
7545
|
-
ExtMapLine.regex = new RegExp(`^extmap:(${NUM})(?:/(${_a$3.EXTMAP_DIRECTION}))? (${ANY_NON_WS})(?: (${REST}))?`);
|
|
7546
|
-
|
|
7547
|
-
class FingerprintLine extends Line {
|
|
7548
|
-
constructor(fingerprint) {
|
|
7549
|
-
super();
|
|
7550
|
-
this.fingerprint = fingerprint;
|
|
7551
|
-
}
|
|
7552
|
-
static fromSdpLine(line) {
|
|
7553
|
-
if (!FingerprintLine.regex.test(line)) {
|
|
7554
|
-
return undefined;
|
|
7555
|
-
}
|
|
7556
|
-
const tokens = line.match(FingerprintLine.regex);
|
|
7557
|
-
const fingerprint = tokens[1];
|
|
7558
|
-
return new FingerprintLine(fingerprint);
|
|
7559
|
-
}
|
|
7560
|
-
toSdpLine() {
|
|
7561
|
-
return `a=fingerprint:${this.fingerprint}`;
|
|
7562
|
-
}
|
|
7563
|
-
}
|
|
7564
|
-
FingerprintLine.regex = new RegExp(`^fingerprint:(${REST})`);
|
|
7565
|
-
|
|
7566
|
-
function parseFmtpParams(fmtpParams) {
|
|
7567
|
-
fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
|
|
7568
|
-
const fmtpObj = new Map();
|
|
7569
|
-
if (/^\d+([,/-]\d+)+$/.test(fmtpParams)) {
|
|
7570
|
-
fmtpObj.set(fmtpParams, undefined);
|
|
7571
|
-
return fmtpObj;
|
|
7572
|
-
}
|
|
7573
|
-
fmtpParams.split(';').forEach((param) => {
|
|
7574
|
-
const paramArr = param && param.split('=');
|
|
7575
|
-
if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
|
|
7576
|
-
throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
|
|
7577
|
-
}
|
|
7578
|
-
fmtpObj.set(paramArr[0], paramArr[1]);
|
|
7579
|
-
});
|
|
7580
|
-
return fmtpObj;
|
|
7581
|
-
}
|
|
7582
|
-
class FmtpLine extends Line {
|
|
7583
|
-
constructor(payloadType, params) {
|
|
7584
|
-
super();
|
|
7585
|
-
this.payloadType = payloadType;
|
|
7586
|
-
this.params = params;
|
|
7587
|
-
}
|
|
7588
|
-
static fromSdpLine(line) {
|
|
7589
|
-
if (!FmtpLine.regex.test(line)) {
|
|
7590
|
-
return undefined;
|
|
7591
|
-
}
|
|
7592
|
-
const tokens = line.match(FmtpLine.regex);
|
|
7593
|
-
const payloadType = parseInt(tokens[1], 10);
|
|
7594
|
-
const params = tokens[2];
|
|
7595
|
-
return new FmtpLine(payloadType, parseFmtpParams(params));
|
|
7596
|
-
}
|
|
7597
|
-
toSdpLine() {
|
|
7598
|
-
const fmtParams = Array.from(this.params.keys())
|
|
7599
|
-
.map((key) => {
|
|
7600
|
-
if (this.params.get(key) !== undefined) {
|
|
7601
|
-
return `${key}=${this.params.get(key)}`;
|
|
7602
|
-
}
|
|
7603
|
-
return `${key}`;
|
|
7604
|
-
})
|
|
7605
|
-
.join(';');
|
|
7606
|
-
return `a=fmtp:${this.payloadType} ${fmtParams}`;
|
|
7607
|
-
}
|
|
7608
|
-
}
|
|
7609
|
-
FmtpLine.regex = new RegExp(`^fmtp:(${NUM}) (${REST})`);
|
|
7610
|
-
|
|
7611
|
-
class IceOptionsLine extends Line {
|
|
7612
|
-
constructor(options) {
|
|
7613
|
-
super();
|
|
7614
|
-
this.options = options;
|
|
7615
|
-
}
|
|
7616
|
-
static fromSdpLine(line) {
|
|
7617
|
-
if (!IceOptionsLine.regex.test(line)) {
|
|
7618
|
-
return undefined;
|
|
7619
|
-
}
|
|
7620
|
-
const tokens = line.match(IceOptionsLine.regex);
|
|
7621
|
-
const options = tokens[1].split(' ');
|
|
7622
|
-
return new IceOptionsLine(options);
|
|
7623
|
-
}
|
|
7624
|
-
toSdpLine() {
|
|
7625
|
-
return `a=ice-options:${this.options.join(' ')}`;
|
|
7626
|
-
}
|
|
7627
|
-
}
|
|
7628
|
-
IceOptionsLine.regex = new RegExp(`^ice-options:(${REST})$`);
|
|
7629
|
-
|
|
7630
|
-
class IcePwdLine extends Line {
|
|
7631
|
-
constructor(pwd) {
|
|
7632
|
-
super();
|
|
7633
|
-
this.pwd = pwd;
|
|
7634
|
-
}
|
|
7635
|
-
static fromSdpLine(line) {
|
|
7636
|
-
if (!IcePwdLine.regex.test(line)) {
|
|
7637
|
-
return undefined;
|
|
7638
|
-
}
|
|
7639
|
-
const tokens = line.match(IcePwdLine.regex);
|
|
7640
|
-
const pwd = tokens[1];
|
|
7641
|
-
return new IcePwdLine(pwd);
|
|
7642
|
-
}
|
|
7643
|
-
toSdpLine() {
|
|
7644
|
-
return `a=ice-pwd:${this.pwd}`;
|
|
7645
|
-
}
|
|
7646
|
-
}
|
|
7647
|
-
IcePwdLine.regex = new RegExp(`^ice-pwd:(${ANY_NON_WS})$`);
|
|
7648
|
-
|
|
7649
|
-
class IceUfragLine extends Line {
|
|
7650
|
-
constructor(ufrag) {
|
|
7651
|
-
super();
|
|
7652
|
-
this.ufrag = ufrag;
|
|
7653
|
-
}
|
|
7654
|
-
static fromSdpLine(line) {
|
|
7655
|
-
if (!IceUfragLine.regex.test(line)) {
|
|
7656
|
-
return undefined;
|
|
7657
|
-
}
|
|
7658
|
-
const tokens = line.match(IceUfragLine.regex);
|
|
7659
|
-
const ufrag = tokens[1];
|
|
7660
|
-
return new IceUfragLine(ufrag);
|
|
7661
|
-
}
|
|
7662
|
-
toSdpLine() {
|
|
7663
|
-
return `a=ice-ufrag:${this.ufrag}`;
|
|
7664
|
-
}
|
|
7665
|
-
}
|
|
7666
|
-
IceUfragLine.regex = new RegExp(`^ice-ufrag:(${ANY_NON_WS})$`);
|
|
7667
|
-
|
|
7668
|
-
class MaxMessageSizeLine extends Line {
|
|
7669
|
-
constructor(maxMessageSize) {
|
|
7670
|
-
super();
|
|
7671
|
-
this.maxMessageSize = maxMessageSize;
|
|
7672
|
-
}
|
|
7673
|
-
static fromSdpLine(line) {
|
|
7674
|
-
if (!MaxMessageSizeLine.regex.test(line)) {
|
|
7675
|
-
return undefined;
|
|
7676
|
-
}
|
|
7677
|
-
const tokens = line.match(MaxMessageSizeLine.regex);
|
|
7678
|
-
const maxMessageSize = parseInt(tokens[1], 10);
|
|
7679
|
-
return new MaxMessageSizeLine(maxMessageSize);
|
|
7680
|
-
}
|
|
7681
|
-
toSdpLine() {
|
|
7682
|
-
return `a=max-message-size:${this.maxMessageSize}`;
|
|
7683
|
-
}
|
|
7684
|
-
}
|
|
7685
|
-
MaxMessageSizeLine.regex = new RegExp(`^max-message-size:(${NUM})`);
|
|
7686
|
-
|
|
7687
|
-
var _a$2;
|
|
7688
|
-
class MediaLine extends Line {
|
|
7689
|
-
constructor(type, port, protocol, formats) {
|
|
7690
|
-
super();
|
|
7691
|
-
this.type = type;
|
|
7692
|
-
this.port = port;
|
|
7693
|
-
this.protocol = protocol;
|
|
7694
|
-
this.formats = formats;
|
|
7695
|
-
}
|
|
7696
|
-
static fromSdpLine(line) {
|
|
7697
|
-
if (!MediaLine.regex.test(line)) {
|
|
7698
|
-
return undefined;
|
|
7699
|
-
}
|
|
7700
|
-
const tokens = line.match(MediaLine.regex);
|
|
7701
|
-
const type = tokens[1];
|
|
7702
|
-
const port = parseInt(tokens[2], 10);
|
|
7703
|
-
const protocol = tokens[3];
|
|
7704
|
-
const formats = tokens[4].split(' ');
|
|
7705
|
-
return new MediaLine(type, port, protocol, formats);
|
|
7706
|
-
}
|
|
7707
|
-
toSdpLine() {
|
|
7708
|
-
return `m=${this.type} ${this.port} ${this.protocol} ${this.formats.join(' ')}`;
|
|
7709
|
-
}
|
|
7710
|
-
}
|
|
7711
|
-
_a$2 = MediaLine;
|
|
7712
|
-
MediaLine.MEDIA_TYPE = 'audio|video|application';
|
|
7713
|
-
MediaLine.regex = new RegExp(`^(${_a$2.MEDIA_TYPE}) (${NUM}) (${ANY_NON_WS}) (${REST})`);
|
|
7714
|
-
|
|
7715
|
-
class MidLine extends Line {
|
|
7716
|
-
constructor(mid) {
|
|
7717
|
-
super();
|
|
7718
|
-
this.mid = mid;
|
|
7719
|
-
}
|
|
7720
|
-
static fromSdpLine(line) {
|
|
7721
|
-
if (!MidLine.regex.test(line)) {
|
|
7722
|
-
return undefined;
|
|
7723
|
-
}
|
|
7724
|
-
const tokens = line.match(MidLine.regex);
|
|
7725
|
-
const mid = tokens[1];
|
|
7726
|
-
return new MidLine(mid);
|
|
7727
|
-
}
|
|
7728
|
-
toSdpLine() {
|
|
7729
|
-
return `a=mid:${this.mid}`;
|
|
7730
|
-
}
|
|
7731
|
-
}
|
|
7732
|
-
MidLine.regex = new RegExp(`^mid:(${ANY_NON_WS})$`);
|
|
7733
|
-
|
|
7734
|
-
class OriginLine extends Line {
|
|
7735
|
-
constructor(username, sessionId, sessionVersion, netType, addrType, ipAddr) {
|
|
7736
|
-
super();
|
|
7737
|
-
this.username = username;
|
|
7738
|
-
this.sessionId = sessionId;
|
|
7739
|
-
this.sessionVersion = sessionVersion;
|
|
7740
|
-
this.netType = netType;
|
|
7741
|
-
this.addrType = addrType;
|
|
7742
|
-
this.ipAddr = ipAddr;
|
|
7743
|
-
}
|
|
7744
|
-
static fromSdpLine(line) {
|
|
7745
|
-
if (!OriginLine.regex.test(line)) {
|
|
7746
|
-
return undefined;
|
|
7747
|
-
}
|
|
7748
|
-
const tokens = line.match(OriginLine.regex);
|
|
7749
|
-
const username = tokens[1];
|
|
7750
|
-
const sessionId = tokens[2];
|
|
7751
|
-
const sessionVersion = parseInt(tokens[3], 10);
|
|
7752
|
-
const netType = tokens[4];
|
|
7753
|
-
const addrType = tokens[5];
|
|
7754
|
-
const ipAddr = tokens[6];
|
|
7755
|
-
return new OriginLine(username, sessionId, sessionVersion, netType, addrType, ipAddr);
|
|
7756
|
-
}
|
|
7757
|
-
toSdpLine() {
|
|
7758
|
-
return `o=${this.username} ${this.sessionId} ${this.sessionVersion} ${this.netType} ${this.addrType} ${this.ipAddr}`;
|
|
7759
|
-
}
|
|
7760
|
-
}
|
|
7761
|
-
OriginLine.regex = new RegExp(`^(${ANY_NON_WS}) (${ANY_NON_WS}) (${NUM}) (${ANY_NON_WS}) (${ANY_NON_WS}) (${ANY_NON_WS})`);
|
|
7762
|
-
|
|
7763
|
-
var _a$1;
|
|
7764
|
-
class RidLine extends Line {
|
|
7765
|
-
constructor(id, direction, params) {
|
|
7766
|
-
super();
|
|
7767
|
-
this.id = id;
|
|
7768
|
-
this.direction = direction;
|
|
7769
|
-
this.params = params;
|
|
7770
|
-
}
|
|
7771
|
-
static fromSdpLine(line) {
|
|
7772
|
-
if (!RidLine.regex.test(line)) {
|
|
7773
|
-
return undefined;
|
|
7774
|
-
}
|
|
7775
|
-
const tokens = line.match(RidLine.regex);
|
|
7776
|
-
const id = tokens[1];
|
|
7777
|
-
const direction = tokens[2];
|
|
7778
|
-
const params = tokens[3];
|
|
7779
|
-
return new RidLine(id, direction, params);
|
|
7780
|
-
}
|
|
7781
|
-
toSdpLine() {
|
|
7782
|
-
let str = '';
|
|
7783
|
-
str += `a=rid:${this.id} ${this.direction}`;
|
|
7784
|
-
if (this.params) {
|
|
7785
|
-
str += ` ${this.params}`;
|
|
7786
|
-
}
|
|
7787
|
-
return str;
|
|
7788
|
-
}
|
|
7789
|
-
}
|
|
7790
|
-
_a$1 = RidLine;
|
|
7791
|
-
RidLine.RID_ID = `[\\w-]+`;
|
|
7792
|
-
RidLine.RID_DIRECTION = `\\bsend\\b|\\brecv\\b`;
|
|
7793
|
-
RidLine.regex = new RegExp(`^rid:(${_a$1.RID_ID}) (${_a$1.RID_DIRECTION})(?:${SP}(${REST}))?`);
|
|
7794
|
-
|
|
7795
|
-
class RtcpMuxLine extends Line {
|
|
7796
|
-
static fromSdpLine(line) {
|
|
7797
|
-
if (!RtcpMuxLine.regex.test(line)) {
|
|
7798
|
-
return undefined;
|
|
7799
|
-
}
|
|
7800
|
-
return new RtcpMuxLine();
|
|
7801
|
-
}
|
|
7802
|
-
toSdpLine() {
|
|
7803
|
-
return `a=rtcp-mux`;
|
|
7804
|
-
}
|
|
7805
|
-
}
|
|
7806
|
-
RtcpMuxLine.regex = /^rtcp-mux$/;
|
|
7807
|
-
|
|
7808
|
-
class RtcpFbLine extends Line {
|
|
7809
|
-
constructor(payloadType, feedback) {
|
|
7810
|
-
super();
|
|
7811
|
-
this.payloadType = payloadType;
|
|
7812
|
-
this.feedback = feedback;
|
|
7813
|
-
}
|
|
7814
|
-
static fromSdpLine(line) {
|
|
7815
|
-
if (!RtcpFbLine.regex.test(line)) {
|
|
7816
|
-
return undefined;
|
|
7817
|
-
}
|
|
7818
|
-
const tokens = line.match(RtcpFbLine.regex);
|
|
7819
|
-
const payloadType = parseInt(tokens[1], 10);
|
|
7820
|
-
const feedback = tokens[2];
|
|
7821
|
-
return new RtcpFbLine(payloadType, feedback);
|
|
7822
|
-
}
|
|
7823
|
-
toSdpLine() {
|
|
7824
|
-
return `a=rtcp-fb:${this.payloadType} ${this.feedback}`;
|
|
7825
|
-
}
|
|
7826
|
-
}
|
|
7827
|
-
RtcpFbLine.regex = new RegExp(`^rtcp-fb:(${NUM}) (${REST})`);
|
|
7828
|
-
|
|
7829
|
-
var _a;
|
|
7830
|
-
class RtpMapLine extends Line {
|
|
7831
|
-
constructor(payloadType, encodingName, clockRate, encodingParams) {
|
|
7832
|
-
super();
|
|
7833
|
-
this.payloadType = payloadType;
|
|
7834
|
-
this.encodingName = encodingName;
|
|
7835
|
-
this.clockRate = clockRate;
|
|
7836
|
-
this.encodingParams = encodingParams;
|
|
7837
|
-
}
|
|
7838
|
-
static fromSdpLine(line) {
|
|
7839
|
-
if (!RtpMapLine.regex.test(line)) {
|
|
7840
|
-
return undefined;
|
|
7841
|
-
}
|
|
7842
|
-
const tokens = line.match(RtpMapLine.regex);
|
|
7843
|
-
const payloadType = parseInt(tokens[1], 10);
|
|
7844
|
-
const encodingName = tokens[2];
|
|
7845
|
-
const clockRate = parseInt(tokens[3], 10);
|
|
7846
|
-
const encodingParams = tokens[4];
|
|
7847
|
-
return new RtpMapLine(payloadType, encodingName, clockRate, encodingParams);
|
|
7848
|
-
}
|
|
7849
|
-
toSdpLine() {
|
|
7850
|
-
let str = '';
|
|
7851
|
-
str += `a=rtpmap:${this.payloadType} ${this.encodingName}/${this.clockRate}`;
|
|
7852
|
-
if (this.encodingParams) {
|
|
7853
|
-
str += `/${this.encodingParams}`;
|
|
7854
|
-
}
|
|
7855
|
-
return str;
|
|
7856
|
-
}
|
|
7857
|
-
}
|
|
7858
|
-
_a = RtpMapLine;
|
|
7859
|
-
RtpMapLine.NON_SLASH_TOKEN = '[^\\s/]+';
|
|
7860
|
-
RtpMapLine.regex = new RegExp(`^rtpmap:(${NUM}) (${_a.NON_SLASH_TOKEN})/(${_a.NON_SLASH_TOKEN})(?:/(${_a.NON_SLASH_TOKEN}))?`);
|
|
7861
|
-
|
|
7862
|
-
class SctpPortLine extends Line {
|
|
7863
|
-
constructor(port) {
|
|
7864
|
-
super();
|
|
7865
|
-
this.port = port;
|
|
7866
|
-
}
|
|
7867
|
-
static fromSdpLine(line) {
|
|
7868
|
-
if (!SctpPortLine.regex.test(line)) {
|
|
7869
|
-
return undefined;
|
|
7870
|
-
}
|
|
7871
|
-
const tokens = line.match(SctpPortLine.regex);
|
|
7872
|
-
const port = parseInt(tokens[1], 10);
|
|
7873
|
-
return new SctpPortLine(port);
|
|
7874
|
-
}
|
|
7875
|
-
toSdpLine() {
|
|
7876
|
-
return `a=sctp-port:${this.port}`;
|
|
7877
|
-
}
|
|
7878
|
-
}
|
|
7879
|
-
SctpPortLine.regex = new RegExp(`^sctp-port:(${NUM})`);
|
|
7880
|
-
|
|
7881
|
-
class SessionInformationLine extends Line {
|
|
7882
|
-
constructor(info) {
|
|
7883
|
-
super();
|
|
7884
|
-
this.info = info;
|
|
7885
|
-
}
|
|
7886
|
-
static fromSdpLine(line) {
|
|
7887
|
-
if (!SessionInformationLine.regex.test(line)) {
|
|
7888
|
-
return undefined;
|
|
7889
|
-
}
|
|
7890
|
-
const tokens = line.match(SessionInformationLine.regex);
|
|
7891
|
-
const info = tokens[1];
|
|
7892
|
-
return new SessionInformationLine(info);
|
|
7893
|
-
}
|
|
7894
|
-
toSdpLine() {
|
|
7895
|
-
return `i=${this.info}`;
|
|
7896
|
-
}
|
|
7897
|
-
}
|
|
7898
|
-
SessionInformationLine.regex = new RegExp(`(${REST})`);
|
|
7899
|
-
|
|
7900
|
-
class SessionNameLine extends Line {
|
|
7901
|
-
constructor(name) {
|
|
7902
|
-
super();
|
|
7903
|
-
this.name = name;
|
|
7904
|
-
}
|
|
7905
|
-
static fromSdpLine(line) {
|
|
7906
|
-
if (!SessionNameLine.regex.test(line)) {
|
|
7907
|
-
return undefined;
|
|
7908
|
-
}
|
|
7909
|
-
const tokens = line.match(SessionNameLine.regex);
|
|
7910
|
-
const name = tokens[1];
|
|
7911
|
-
return new SessionNameLine(name);
|
|
7912
|
-
}
|
|
7913
|
-
toSdpLine() {
|
|
7914
|
-
return `s=${this.name}`;
|
|
7915
|
-
}
|
|
7916
|
-
}
|
|
7917
|
-
SessionNameLine.regex = new RegExp(`^(${REST})`);
|
|
7918
|
-
|
|
7919
|
-
class SetupLine extends Line {
|
|
7920
|
-
constructor(setup) {
|
|
7921
|
-
super();
|
|
7922
|
-
this.setup = setup;
|
|
7923
|
-
}
|
|
7924
|
-
static fromSdpLine(line) {
|
|
7925
|
-
if (!SetupLine.regex.test(line)) {
|
|
7926
|
-
return undefined;
|
|
7927
|
-
}
|
|
7928
|
-
const tokens = line.match(SetupLine.regex);
|
|
7929
|
-
const setup = tokens[1];
|
|
7930
|
-
return new SetupLine(setup);
|
|
7931
|
-
}
|
|
7932
|
-
toSdpLine() {
|
|
7933
|
-
return `a=setup:${this.setup}`;
|
|
7934
|
-
}
|
|
7935
|
-
}
|
|
7936
|
-
SetupLine.regex = /^setup:(actpass|active|passive)$/;
|
|
7937
|
-
|
|
7938
|
-
class SimulcastLayer {
|
|
7939
|
-
constructor(id, paused) {
|
|
7940
|
-
this.id = id;
|
|
7941
|
-
this.paused = paused;
|
|
7942
|
-
}
|
|
7943
|
-
toString() {
|
|
7944
|
-
return this.paused ? `~${this.id}` : this.id;
|
|
7945
|
-
}
|
|
7946
|
-
}
|
|
7947
|
-
class SimulcastLayerList {
|
|
7948
|
-
constructor() {
|
|
7949
|
-
this.layers = [];
|
|
7950
|
-
}
|
|
7951
|
-
addLayer(layer) {
|
|
7952
|
-
this.layers.push([layer]);
|
|
7953
|
-
}
|
|
7954
|
-
addLayerWithAlternatives(alternatives) {
|
|
7955
|
-
this.layers.push(alternatives);
|
|
7956
|
-
}
|
|
7957
|
-
get length() {
|
|
7958
|
-
return this.layers.length;
|
|
7959
|
-
}
|
|
7960
|
-
get(index) {
|
|
7961
|
-
return this.layers[index];
|
|
7962
|
-
}
|
|
7963
|
-
static fromString(str) {
|
|
7964
|
-
const layerList = new SimulcastLayerList();
|
|
7965
|
-
const tokens = str.split(';');
|
|
7966
|
-
if (tokens.length === 1 && !tokens[0].trim()) {
|
|
7967
|
-
throw new Error('simulcast stream list empty');
|
|
7968
|
-
}
|
|
7969
|
-
tokens.forEach((token) => {
|
|
7970
|
-
if (!token) {
|
|
7971
|
-
throw new Error('simulcast layer list empty');
|
|
7972
|
-
}
|
|
7973
|
-
const ridTokens = token.split(',');
|
|
7974
|
-
const layers = [];
|
|
7975
|
-
ridTokens.forEach((ridToken) => {
|
|
7976
|
-
if (!ridToken || ridToken === '~') {
|
|
7977
|
-
throw new Error('rid empty');
|
|
7978
|
-
}
|
|
7979
|
-
const paused = ridToken[0] === '~';
|
|
7980
|
-
const rid = paused ? ridToken.substring(1) : ridToken;
|
|
7981
|
-
layers.push(new SimulcastLayer(rid, paused));
|
|
7982
|
-
});
|
|
7983
|
-
layerList.addLayerWithAlternatives(layers);
|
|
7984
|
-
});
|
|
7985
|
-
return layerList;
|
|
7986
|
-
}
|
|
7987
|
-
toString() {
|
|
7988
|
-
return this.layers
|
|
7989
|
-
.map((altArray) => altArray.map((v) => v.toString()).join(','))
|
|
7990
|
-
.join(';');
|
|
7991
|
-
}
|
|
7992
|
-
}
|
|
7993
|
-
class SimulcastLine extends Line {
|
|
7994
|
-
constructor(sendLayers, recvLayers) {
|
|
7995
|
-
super();
|
|
7996
|
-
this.sendLayers = sendLayers;
|
|
7997
|
-
this.recvLayers = recvLayers;
|
|
7998
|
-
}
|
|
7999
|
-
static fromSdpLine(line) {
|
|
8000
|
-
if (!SimulcastLine.regex.test(line)) {
|
|
8001
|
-
return undefined;
|
|
8002
|
-
}
|
|
8003
|
-
const tokens = line.match(SimulcastLine.regex);
|
|
8004
|
-
const bidirectional = tokens[3] && tokens[4];
|
|
8005
|
-
const firstDirection = tokens[1];
|
|
8006
|
-
const layerList1 = SimulcastLayerList.fromString(tokens[2]);
|
|
8007
|
-
let layerList2 = new SimulcastLayerList();
|
|
8008
|
-
if (bidirectional) {
|
|
8009
|
-
const secondDirection = tokens[3];
|
|
8010
|
-
if (firstDirection === secondDirection) {
|
|
8011
|
-
return undefined;
|
|
8012
|
-
}
|
|
8013
|
-
layerList2 = SimulcastLayerList.fromString(tokens[4]);
|
|
8014
|
-
}
|
|
8015
|
-
let sendLayerList;
|
|
8016
|
-
let recvLayerList;
|
|
8017
|
-
if (firstDirection === 'send') {
|
|
8018
|
-
sendLayerList = layerList1;
|
|
8019
|
-
recvLayerList = layerList2;
|
|
8020
|
-
}
|
|
8021
|
-
else {
|
|
8022
|
-
sendLayerList = layerList2;
|
|
8023
|
-
recvLayerList = layerList1;
|
|
8024
|
-
}
|
|
8025
|
-
return new SimulcastLine(sendLayerList, recvLayerList);
|
|
8026
|
-
}
|
|
8027
|
-
toSdpLine() {
|
|
8028
|
-
let str = 'a=simulcast:';
|
|
8029
|
-
if (this.sendLayers.length) {
|
|
8030
|
-
str += `send ${this.sendLayers.toString()}`;
|
|
8031
|
-
if (this.recvLayers.length) {
|
|
8032
|
-
str += ` `;
|
|
8033
|
-
}
|
|
8034
|
-
}
|
|
8035
|
-
if (this.recvLayers.length) {
|
|
8036
|
-
str += `recv ${this.recvLayers.toString()}`;
|
|
8037
|
-
}
|
|
8038
|
-
return str;
|
|
8039
|
-
}
|
|
8040
|
-
}
|
|
8041
|
-
SimulcastLine.regex = new RegExp(`^simulcast:(send|recv) (${ANY_NON_WS})(?: (send|recv) (${ANY_NON_WS}))?`);
|
|
8042
|
-
|
|
8043
|
-
class SsrcLine extends Line {
|
|
8044
|
-
constructor(ssrcId, attribute, attributeValue = undefined, attributeData = undefined) {
|
|
8045
|
-
super();
|
|
8046
|
-
this.ssrcId = ssrcId;
|
|
8047
|
-
this.attribute = attribute;
|
|
8048
|
-
this.attributeValue = attributeValue;
|
|
8049
|
-
this.attributeData = attributeData;
|
|
8050
|
-
}
|
|
8051
|
-
static fromSdpLine(line) {
|
|
8052
|
-
if (!SsrcLine.regex.test(line)) {
|
|
8053
|
-
return undefined;
|
|
8054
|
-
}
|
|
8055
|
-
const tokens = line.match(SsrcLine.regex);
|
|
8056
|
-
const ssrcId = parseInt(tokens[1], 10);
|
|
8057
|
-
const attribute = tokens[2];
|
|
8058
|
-
const attributeValue = tokens[3];
|
|
8059
|
-
const attributeData = tokens[4];
|
|
8060
|
-
return new SsrcLine(ssrcId, attribute, attributeValue, attributeData);
|
|
8061
|
-
}
|
|
8062
|
-
toSdpLine() {
|
|
8063
|
-
let str = `a=ssrc:${this.ssrcId} ${this.attribute}`;
|
|
8064
|
-
if (this.attributeValue) {
|
|
8065
|
-
str += `:${this.attributeValue}`;
|
|
8066
|
-
}
|
|
8067
|
-
if (this.attributeData) {
|
|
8068
|
-
str += ` ${this.attributeData}`;
|
|
8069
|
-
}
|
|
8070
|
-
return str;
|
|
8071
|
-
}
|
|
8072
|
-
}
|
|
8073
|
-
SsrcLine.regex = new RegExp(`^ssrc:(${NUM}) (${SDP_TOKEN})(?::(${SDP_TOKEN})?(?: (${ANY_NON_WS}))?)?$`);
|
|
8074
|
-
|
|
8075
|
-
class SsrcGroupLine extends Line {
|
|
8076
|
-
constructor(semantics, ssrcs) {
|
|
8077
|
-
super();
|
|
8078
|
-
this.semantics = semantics;
|
|
8079
|
-
this.ssrcs = ssrcs;
|
|
8080
|
-
}
|
|
8081
|
-
static fromSdpLine(line) {
|
|
8082
|
-
if (!SsrcGroupLine.regex.test(line)) {
|
|
8083
|
-
return undefined;
|
|
8084
|
-
}
|
|
8085
|
-
const tokens = line.match(SsrcGroupLine.regex);
|
|
8086
|
-
const semantics = tokens[1];
|
|
8087
|
-
const ssrcs = tokens[2].split(' ').map((ssrcStr) => parseInt(ssrcStr, 10));
|
|
8088
|
-
return new SsrcGroupLine(semantics, ssrcs);
|
|
8089
|
-
}
|
|
8090
|
-
toSdpLine() {
|
|
8091
|
-
return `a=ssrc-group:${this.semantics} ${this.ssrcs.join(' ')}`;
|
|
8092
|
-
}
|
|
8093
|
-
}
|
|
8094
|
-
SsrcGroupLine.regex = new RegExp(`^ssrc-group:(SIM|FID|FEC) ((?:${NUM}${SP}*)+)`);
|
|
8095
|
-
|
|
8096
|
-
class TimingLine extends Line {
|
|
8097
|
-
constructor(startTime, stopTime) {
|
|
8098
|
-
super();
|
|
8099
|
-
this.startTime = startTime;
|
|
8100
|
-
this.stopTime = stopTime;
|
|
8101
|
-
}
|
|
8102
|
-
static fromSdpLine(line) {
|
|
8103
|
-
if (!TimingLine.regex.test(line)) {
|
|
8104
|
-
return undefined;
|
|
8105
|
-
}
|
|
8106
|
-
const tokens = line.match(TimingLine.regex);
|
|
8107
|
-
const startTime = parseInt(tokens[1], 10);
|
|
8108
|
-
const stopTime = parseInt(tokens[2], 10);
|
|
8109
|
-
return new TimingLine(startTime, stopTime);
|
|
8110
|
-
}
|
|
8111
|
-
toSdpLine() {
|
|
8112
|
-
return `t=${this.startTime} ${this.stopTime}`;
|
|
8113
|
-
}
|
|
8114
|
-
}
|
|
8115
|
-
TimingLine.regex = new RegExp(`^(${NUM}) (${NUM})`);
|
|
8116
|
-
|
|
8117
|
-
class VersionLine extends Line {
|
|
8118
|
-
constructor(version) {
|
|
8119
|
-
super();
|
|
8120
|
-
this.version = version;
|
|
8121
|
-
}
|
|
8122
|
-
static fromSdpLine(line) {
|
|
8123
|
-
if (!VersionLine.regex.test(line)) {
|
|
8124
|
-
return undefined;
|
|
8125
|
-
}
|
|
8126
|
-
const tokens = line.match(VersionLine.regex);
|
|
8127
|
-
const version = parseInt(tokens[1], 10);
|
|
8128
|
-
return new VersionLine(version);
|
|
8129
|
-
}
|
|
8130
|
-
toSdpLine() {
|
|
8131
|
-
return `v=${this.version}`;
|
|
8132
|
-
}
|
|
8133
|
-
}
|
|
8134
|
-
VersionLine.regex = new RegExp(`^(${NUM})$`);
|
|
8135
|
-
|
|
8136
|
-
class UnknownLine extends Line {
|
|
8137
|
-
constructor(value) {
|
|
8138
|
-
super();
|
|
8139
|
-
this.value = value;
|
|
8140
|
-
}
|
|
8141
|
-
static fromSdpLine(line) {
|
|
8142
|
-
const tokens = line.match(UnknownLine.regex);
|
|
8143
|
-
const value = tokens[1];
|
|
8144
|
-
return new UnknownLine(value);
|
|
8145
|
-
}
|
|
8146
|
-
toSdpLine() {
|
|
8147
|
-
return `${this.value}`;
|
|
8148
|
-
}
|
|
8149
|
-
}
|
|
8150
|
-
UnknownLine.regex = new RegExp(`(${REST})`);
|
|
8151
|
-
|
|
8152
|
-
class IceInfo {
|
|
8153
|
-
constructor() {
|
|
8154
|
-
this.candidates = [];
|
|
8155
|
-
}
|
|
8156
|
-
addLine(line) {
|
|
8157
|
-
if (line instanceof IceUfragLine) {
|
|
8158
|
-
this.ufrag = line;
|
|
8159
|
-
return true;
|
|
8160
|
-
}
|
|
8161
|
-
if (line instanceof IcePwdLine) {
|
|
8162
|
-
this.pwd = line;
|
|
8163
|
-
return true;
|
|
8164
|
-
}
|
|
8165
|
-
if (line instanceof IceOptionsLine) {
|
|
8166
|
-
this.options = line;
|
|
8167
|
-
return true;
|
|
8168
|
-
}
|
|
8169
|
-
if (line instanceof CandidateLine) {
|
|
8170
|
-
this.candidates.push(line);
|
|
8171
|
-
return true;
|
|
8172
|
-
}
|
|
8173
|
-
return false;
|
|
8174
|
-
}
|
|
8175
|
-
toLines() {
|
|
8176
|
-
const lines = [];
|
|
8177
|
-
if (this.ufrag) {
|
|
8178
|
-
lines.push(this.ufrag);
|
|
8179
|
-
}
|
|
8180
|
-
if (this.pwd) {
|
|
8181
|
-
lines.push(this.pwd);
|
|
8182
|
-
}
|
|
8183
|
-
if (this.options) {
|
|
8184
|
-
lines.push(this.options);
|
|
8185
|
-
}
|
|
8186
|
-
this.candidates.forEach((candidate) => lines.push(candidate));
|
|
8187
|
-
return lines;
|
|
8188
|
-
}
|
|
8189
|
-
}
|
|
8190
|
-
|
|
8191
|
-
class MediaDescription {
|
|
8192
|
-
constructor(type, port, protocol) {
|
|
8193
|
-
this.iceInfo = new IceInfo();
|
|
8194
|
-
this.otherLines = [];
|
|
8195
|
-
this.type = type;
|
|
8196
|
-
this.port = port;
|
|
8197
|
-
this.protocol = protocol;
|
|
8198
|
-
}
|
|
8199
|
-
findOtherLine(ty) {
|
|
8200
|
-
return this.otherLines.find((line) => line instanceof ty);
|
|
8201
|
-
}
|
|
8202
|
-
addLine(line) {
|
|
8203
|
-
if (line instanceof BundleGroupLine) {
|
|
8204
|
-
throw new Error(`Error: bundle group line not allowed in media description`);
|
|
8205
|
-
}
|
|
8206
|
-
if (line instanceof BandwidthLine) {
|
|
8207
|
-
this.bandwidth = line;
|
|
8208
|
-
return true;
|
|
8209
|
-
}
|
|
8210
|
-
if (line instanceof MidLine) {
|
|
8211
|
-
this.mid = line.mid;
|
|
8212
|
-
return true;
|
|
8213
|
-
}
|
|
8214
|
-
if (line instanceof FingerprintLine) {
|
|
8215
|
-
this.fingerprint = line.fingerprint;
|
|
8216
|
-
return true;
|
|
8217
|
-
}
|
|
8218
|
-
if (line instanceof SetupLine) {
|
|
8219
|
-
this.setup = line.setup;
|
|
8220
|
-
return true;
|
|
8221
|
-
}
|
|
8222
|
-
if (line instanceof ConnectionLine) {
|
|
8223
|
-
this.connection = line;
|
|
8224
|
-
return true;
|
|
8225
|
-
}
|
|
8226
|
-
if (line instanceof ContentLine) {
|
|
8227
|
-
this.content = line;
|
|
8228
|
-
return true;
|
|
8229
|
-
}
|
|
8230
|
-
return this.iceInfo.addLine(line);
|
|
8231
|
-
}
|
|
8232
|
-
}
|
|
8233
|
-
|
|
8234
|
-
class ApplicationMediaDescription extends MediaDescription {
|
|
8235
|
-
constructor(mediaLine) {
|
|
8236
|
-
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
8237
|
-
this.fmts = [];
|
|
8238
|
-
this.fmts = mediaLine.formats;
|
|
8239
|
-
}
|
|
8240
|
-
toLines() {
|
|
8241
|
-
const lines = [];
|
|
8242
|
-
lines.push(new MediaLine(this.type, this.port, this.protocol, this.fmts));
|
|
8243
|
-
if (this.connection) {
|
|
8244
|
-
lines.push(this.connection);
|
|
8245
|
-
}
|
|
8246
|
-
if (this.bandwidth) {
|
|
8247
|
-
lines.push(this.bandwidth);
|
|
8248
|
-
}
|
|
8249
|
-
lines.push(...this.iceInfo.toLines());
|
|
8250
|
-
if (this.fingerprint) {
|
|
8251
|
-
lines.push(new FingerprintLine(this.fingerprint));
|
|
8252
|
-
}
|
|
8253
|
-
if (this.setup) {
|
|
8254
|
-
lines.push(new SetupLine(this.setup));
|
|
8255
|
-
}
|
|
8256
|
-
if (this.mid) {
|
|
8257
|
-
lines.push(new MidLine(this.mid));
|
|
8258
|
-
}
|
|
8259
|
-
if (this.content) {
|
|
8260
|
-
lines.push(this.content);
|
|
8261
|
-
}
|
|
8262
|
-
if (this.sctpPort) {
|
|
8263
|
-
lines.push(new SctpPortLine(this.sctpPort));
|
|
8264
|
-
}
|
|
8265
|
-
if (this.maxMessageSize) {
|
|
8266
|
-
lines.push(new MaxMessageSizeLine(this.maxMessageSize));
|
|
8267
|
-
}
|
|
8268
|
-
lines.push(...this.otherLines);
|
|
8269
|
-
return lines;
|
|
8270
|
-
}
|
|
8271
|
-
addLine(line) {
|
|
8272
|
-
if (super.addLine(line)) {
|
|
8273
|
-
return true;
|
|
8274
|
-
}
|
|
8275
|
-
if (line instanceof MediaLine) {
|
|
8276
|
-
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
8277
|
-
}
|
|
8278
|
-
if (line instanceof SctpPortLine) {
|
|
8279
|
-
this.sctpPort = line.port;
|
|
8280
|
-
return true;
|
|
8281
|
-
}
|
|
8282
|
-
if (line instanceof MaxMessageSizeLine) {
|
|
8283
|
-
this.maxMessageSize = line.maxMessageSize;
|
|
8284
|
-
return true;
|
|
8285
|
-
}
|
|
8286
|
-
this.otherLines.push(line);
|
|
8287
|
-
return true;
|
|
8288
|
-
}
|
|
8289
|
-
}
|
|
8290
|
-
|
|
8291
|
-
class CodecInfo {
|
|
8292
|
-
constructor(pt) {
|
|
8293
|
-
this.fmtParams = new Map();
|
|
8294
|
-
this.feedback = [];
|
|
8295
|
-
this.pt = pt;
|
|
8296
|
-
}
|
|
8297
|
-
addLine(line) {
|
|
8298
|
-
if (line instanceof RtpMapLine) {
|
|
8299
|
-
this.name = line.encodingName;
|
|
8300
|
-
this.clockRate = line.clockRate;
|
|
8301
|
-
this.encodingParams = line.encodingParams;
|
|
8302
|
-
return true;
|
|
8303
|
-
}
|
|
8304
|
-
if (line instanceof FmtpLine) {
|
|
8305
|
-
this.fmtParams = new Map([
|
|
8306
|
-
...Array.from(this.fmtParams.entries()),
|
|
8307
|
-
...Array.from(line.params.entries()),
|
|
8308
|
-
]);
|
|
8309
|
-
if (line.params.has('apt')) {
|
|
8310
|
-
const apt = line.params.get('apt');
|
|
8311
|
-
this.primaryCodecPt = parseInt(apt, 10);
|
|
8312
|
-
}
|
|
8313
|
-
return true;
|
|
8314
|
-
}
|
|
8315
|
-
if (line instanceof RtcpFbLine) {
|
|
8316
|
-
this.feedback.push(line.feedback);
|
|
8317
|
-
return true;
|
|
8318
|
-
}
|
|
8319
|
-
return false;
|
|
8320
|
-
}
|
|
8321
|
-
toLines() {
|
|
8322
|
-
const lines = [];
|
|
8323
|
-
if (this.name && this.clockRate) {
|
|
8324
|
-
lines.push(new RtpMapLine(this.pt, this.name, this.clockRate, this.encodingParams));
|
|
8325
|
-
}
|
|
8326
|
-
this.feedback.forEach((fb) => {
|
|
8327
|
-
lines.push(new RtcpFbLine(this.pt, fb));
|
|
8328
|
-
});
|
|
8329
|
-
if (this.fmtParams.size > 0) {
|
|
8330
|
-
lines.push(new FmtpLine(this.pt, this.fmtParams));
|
|
8331
|
-
}
|
|
8332
|
-
return lines;
|
|
8333
|
-
}
|
|
8334
|
-
}
|
|
8335
|
-
|
|
8336
|
-
class AvMediaDescription extends MediaDescription {
|
|
8337
|
-
constructor(mediaLine) {
|
|
8338
|
-
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
8339
|
-
this.pts = [];
|
|
8340
|
-
this.extMaps = new Map();
|
|
8341
|
-
this.rids = [];
|
|
8342
|
-
this.codecs = new Map();
|
|
8343
|
-
this.rtcpMux = false;
|
|
8344
|
-
this.ssrcs = [];
|
|
8345
|
-
this.ssrcGroups = [];
|
|
8346
|
-
this.pts = mediaLine.formats.map((fmt) => {
|
|
8347
|
-
return parseInt(fmt, 10);
|
|
8348
|
-
});
|
|
8349
|
-
this.pts.forEach((pt) => this.codecs.set(pt, new CodecInfo(pt)));
|
|
8350
|
-
}
|
|
8351
|
-
toLines() {
|
|
8352
|
-
const lines = [];
|
|
8353
|
-
lines.push(new MediaLine(this.type, this.port, this.protocol, this.pts.map((pt) => `${pt}`)));
|
|
8354
|
-
if (this.connection) {
|
|
8355
|
-
lines.push(this.connection);
|
|
8356
|
-
}
|
|
8357
|
-
if (this.bandwidth) {
|
|
8358
|
-
lines.push(this.bandwidth);
|
|
8359
|
-
}
|
|
8360
|
-
lines.push(...this.iceInfo.toLines());
|
|
8361
|
-
if (this.fingerprint) {
|
|
8362
|
-
lines.push(new FingerprintLine(this.fingerprint));
|
|
8363
|
-
}
|
|
8364
|
-
if (this.setup) {
|
|
8365
|
-
lines.push(new SetupLine(this.setup));
|
|
8366
|
-
}
|
|
8367
|
-
if (this.mid) {
|
|
8368
|
-
lines.push(new MidLine(this.mid));
|
|
8369
|
-
}
|
|
8370
|
-
if (this.rtcpMux) {
|
|
8371
|
-
lines.push(new RtcpMuxLine());
|
|
8372
|
-
}
|
|
8373
|
-
if (this.content) {
|
|
8374
|
-
lines.push(this.content);
|
|
8375
|
-
}
|
|
8376
|
-
this.extMaps.forEach((extMap) => lines.push(extMap));
|
|
8377
|
-
this.rids.forEach((rid) => lines.push(rid));
|
|
8378
|
-
if (this.simulcast) {
|
|
8379
|
-
lines.push(this.simulcast);
|
|
8380
|
-
}
|
|
8381
|
-
if (this.direction) {
|
|
8382
|
-
lines.push(new DirectionLine(this.direction));
|
|
8383
|
-
}
|
|
8384
|
-
this.codecs.forEach((codec) => lines.push(...codec.toLines()));
|
|
8385
|
-
lines.push(...this.ssrcs);
|
|
8386
|
-
lines.push(...this.ssrcGroups);
|
|
8387
|
-
lines.push(...this.otherLines);
|
|
8388
|
-
return lines;
|
|
8389
|
-
}
|
|
8390
|
-
addLine(line) {
|
|
8391
|
-
if (super.addLine(line)) {
|
|
8392
|
-
return true;
|
|
8393
|
-
}
|
|
8394
|
-
if (line instanceof MediaLine) {
|
|
8395
|
-
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
8396
|
-
}
|
|
8397
|
-
if (line instanceof DirectionLine) {
|
|
8398
|
-
this.direction = line.direction;
|
|
8399
|
-
return true;
|
|
8400
|
-
}
|
|
8401
|
-
if (line instanceof ExtMapLine) {
|
|
8402
|
-
if (this.extMaps.has(line.id)) {
|
|
8403
|
-
throw new Error(`Tried to extension with duplicate ID: an extension already exists with ID ${line.id}`);
|
|
8404
|
-
}
|
|
8405
|
-
this.extMaps.set(line.id, line);
|
|
8406
|
-
return true;
|
|
8407
|
-
}
|
|
8408
|
-
if (line instanceof RidLine) {
|
|
8409
|
-
this.rids.push(line);
|
|
8410
|
-
return true;
|
|
8411
|
-
}
|
|
8412
|
-
if (line instanceof RtcpMuxLine) {
|
|
8413
|
-
this.rtcpMux = true;
|
|
8414
|
-
return true;
|
|
8415
|
-
}
|
|
8416
|
-
if (line instanceof SimulcastLine) {
|
|
8417
|
-
this.simulcast = line;
|
|
8418
|
-
return true;
|
|
8419
|
-
}
|
|
8420
|
-
if (line instanceof RtpMapLine || line instanceof FmtpLine || line instanceof RtcpFbLine) {
|
|
8421
|
-
const codec = this.codecs.get(line.payloadType);
|
|
8422
|
-
if (!codec) {
|
|
8423
|
-
throw new Error(`Error: got line for unknown codec: ${line.toSdpLine()}`);
|
|
8424
|
-
}
|
|
8425
|
-
codec.addLine(line);
|
|
8426
|
-
return true;
|
|
8427
|
-
}
|
|
8428
|
-
if (line instanceof SsrcLine) {
|
|
8429
|
-
this.ssrcs.push(line);
|
|
8430
|
-
return true;
|
|
8431
|
-
}
|
|
8432
|
-
if (line instanceof SsrcGroupLine) {
|
|
8433
|
-
this.ssrcGroups.push(line);
|
|
8434
|
-
return true;
|
|
8435
|
-
}
|
|
8436
|
-
this.otherLines.push(line);
|
|
8437
|
-
return true;
|
|
8438
|
-
}
|
|
8439
|
-
getCodecByPt(pt) {
|
|
8440
|
-
return this.codecs.get(pt);
|
|
8441
|
-
}
|
|
8442
|
-
removePt(pt) {
|
|
8443
|
-
const associatedPts = [...this.codecs.values()]
|
|
8444
|
-
.filter((ci) => ci.primaryCodecPt === pt)
|
|
8445
|
-
.map((ci) => ci.pt);
|
|
8446
|
-
const allPtsToRemove = [pt, ...associatedPts];
|
|
8447
|
-
allPtsToRemove.forEach((ptToRemove) => {
|
|
8448
|
-
this.codecs.delete(ptToRemove);
|
|
8449
|
-
});
|
|
8450
|
-
this.pts = this.pts.filter((existingPt) => allPtsToRemove.indexOf(existingPt) === -1);
|
|
8451
|
-
}
|
|
8452
|
-
addExtension({ uri, direction, attributes, id, }) {
|
|
8453
|
-
const getFirstFreeId = () => {
|
|
8454
|
-
let freeId = 1;
|
|
8455
|
-
for (;;) {
|
|
8456
|
-
if (!this.extMaps.has(freeId)) {
|
|
8457
|
-
break;
|
|
8458
|
-
}
|
|
8459
|
-
freeId += 1;
|
|
8460
|
-
}
|
|
8461
|
-
return freeId;
|
|
8462
|
-
};
|
|
8463
|
-
const extId = id || getFirstFreeId();
|
|
8464
|
-
if (this.extMaps.has(extId)) {
|
|
8465
|
-
throw new Error(`Extension with ID ${id} already exists`);
|
|
8466
|
-
}
|
|
8467
|
-
if (extId === 0) {
|
|
8468
|
-
throw new Error(`Extension ID 0 is reserved`);
|
|
8469
|
-
}
|
|
8470
|
-
this.extMaps.set(extId, new ExtMapLine(extId, uri, direction, attributes));
|
|
8471
|
-
}
|
|
8472
|
-
}
|
|
8473
|
-
|
|
8474
|
-
class SessionDescription {
|
|
8475
|
-
constructor() {
|
|
8476
|
-
this.groups = [];
|
|
8477
|
-
this.otherLines = [];
|
|
8478
|
-
}
|
|
8479
|
-
addLine(line) {
|
|
8480
|
-
if (line instanceof VersionLine) {
|
|
8481
|
-
this.version = line;
|
|
8482
|
-
return true;
|
|
8483
|
-
}
|
|
8484
|
-
if (line instanceof OriginLine) {
|
|
8485
|
-
this.origin = line;
|
|
8486
|
-
return true;
|
|
8487
|
-
}
|
|
8488
|
-
if (line instanceof SessionNameLine) {
|
|
8489
|
-
this.sessionName = line;
|
|
8490
|
-
return true;
|
|
8491
|
-
}
|
|
8492
|
-
if (line instanceof SessionInformationLine) {
|
|
8493
|
-
this.information = line;
|
|
8494
|
-
return true;
|
|
8495
|
-
}
|
|
8496
|
-
if (line instanceof TimingLine) {
|
|
8497
|
-
this.timing = line;
|
|
8498
|
-
return true;
|
|
8499
|
-
}
|
|
8500
|
-
if (line instanceof ConnectionLine) {
|
|
8501
|
-
this.connection = line;
|
|
8502
|
-
return true;
|
|
8503
|
-
}
|
|
8504
|
-
if (line instanceof BandwidthLine) {
|
|
8505
|
-
this.bandwidth = line;
|
|
8506
|
-
return true;
|
|
8507
|
-
}
|
|
8508
|
-
if (line instanceof BundleGroupLine) {
|
|
8509
|
-
this.groups.push(line);
|
|
8510
|
-
return true;
|
|
8511
|
-
}
|
|
8512
|
-
this.otherLines.push(line);
|
|
8513
|
-
return true;
|
|
8514
|
-
}
|
|
8515
|
-
toLines() {
|
|
8516
|
-
const lines = [];
|
|
8517
|
-
if (this.version) {
|
|
8518
|
-
lines.push(this.version);
|
|
8519
|
-
}
|
|
8520
|
-
if (this.origin) {
|
|
8521
|
-
lines.push(this.origin);
|
|
8522
|
-
}
|
|
8523
|
-
if (this.sessionName) {
|
|
8524
|
-
lines.push(this.sessionName);
|
|
8525
|
-
}
|
|
8526
|
-
if (this.information) {
|
|
8527
|
-
lines.push(this.information);
|
|
8528
|
-
}
|
|
8529
|
-
if (this.connection) {
|
|
8530
|
-
lines.push(this.connection);
|
|
8531
|
-
}
|
|
8532
|
-
if (this.bandwidth) {
|
|
8533
|
-
lines.push(this.bandwidth);
|
|
8534
|
-
}
|
|
8535
|
-
if (this.timing) {
|
|
8536
|
-
lines.push(this.timing);
|
|
8537
|
-
}
|
|
8538
|
-
if (this.groups) {
|
|
8539
|
-
lines.push(...this.groups);
|
|
8540
|
-
}
|
|
8541
|
-
lines.push(...this.otherLines);
|
|
8542
|
-
return lines;
|
|
8543
|
-
}
|
|
8544
|
-
}
|
|
8545
|
-
|
|
8546
|
-
class Sdp {
|
|
8547
|
-
constructor() {
|
|
8548
|
-
this.session = new SessionDescription();
|
|
8549
|
-
this.media = [];
|
|
8550
|
-
}
|
|
8551
|
-
get avMedia() {
|
|
8552
|
-
return this.media.filter((mi) => mi instanceof AvMediaDescription);
|
|
8553
|
-
}
|
|
8554
|
-
toString() {
|
|
8555
|
-
const lines = [];
|
|
8556
|
-
lines.push(...this.session.toLines());
|
|
8557
|
-
this.media.forEach((m) => lines.push(...m.toLines()));
|
|
8558
|
-
return `${lines.map((l) => l.toSdpLine()).join('\r\n')}\r\n`;
|
|
8559
|
-
}
|
|
8560
|
-
}
|
|
8561
|
-
|
|
8562
|
-
class Grammar {
|
|
8563
|
-
constructor() {
|
|
8564
|
-
this.parsers = new Map();
|
|
8565
|
-
}
|
|
8566
|
-
addParser(lineType, parser) {
|
|
8567
|
-
const parsers = this.parsers.get(lineType) || [];
|
|
8568
|
-
parsers.push(parser);
|
|
8569
|
-
this.parsers.set(lineType, parsers);
|
|
8570
|
-
}
|
|
8571
|
-
getParsers(lineType) {
|
|
8572
|
-
return this.parsers.get(lineType) || [];
|
|
8573
|
-
}
|
|
8574
|
-
}
|
|
8575
|
-
class SdpGrammar extends Grammar {
|
|
8576
|
-
constructor() {
|
|
8577
|
-
super();
|
|
8578
|
-
this.addParser('v', VersionLine.fromSdpLine);
|
|
8579
|
-
this.addParser('o', OriginLine.fromSdpLine);
|
|
8580
|
-
this.addParser('c', ConnectionLine.fromSdpLine);
|
|
8581
|
-
this.addParser('i', SessionInformationLine.fromSdpLine);
|
|
8582
|
-
this.addParser('m', MediaLine.fromSdpLine);
|
|
8583
|
-
this.addParser('s', SessionNameLine.fromSdpLine);
|
|
8584
|
-
this.addParser('t', TimingLine.fromSdpLine);
|
|
8585
|
-
this.addParser('b', BandwidthLine.fromSdpLine);
|
|
8586
|
-
this.addParser('a', RtpMapLine.fromSdpLine);
|
|
8587
|
-
this.addParser('a', RtcpFbLine.fromSdpLine);
|
|
8588
|
-
this.addParser('a', FmtpLine.fromSdpLine);
|
|
8589
|
-
this.addParser('a', DirectionLine.fromSdpLine);
|
|
8590
|
-
this.addParser('a', ExtMapLine.fromSdpLine);
|
|
8591
|
-
this.addParser('a', MidLine.fromSdpLine);
|
|
8592
|
-
this.addParser('a', IceUfragLine.fromSdpLine);
|
|
8593
|
-
this.addParser('a', IcePwdLine.fromSdpLine);
|
|
8594
|
-
this.addParser('a', IceOptionsLine.fromSdpLine);
|
|
8595
|
-
this.addParser('a', FingerprintLine.fromSdpLine);
|
|
8596
|
-
this.addParser('a', SetupLine.fromSdpLine);
|
|
8597
|
-
this.addParser('a', SctpPortLine.fromSdpLine);
|
|
8598
|
-
this.addParser('a', MaxMessageSizeLine.fromSdpLine);
|
|
8599
|
-
this.addParser('a', RtcpMuxLine.fromSdpLine);
|
|
8600
|
-
this.addParser('a', BundleGroupLine.fromSdpLine);
|
|
8601
|
-
this.addParser('a', ContentLine.fromSdpLine);
|
|
8602
|
-
this.addParser('a', RidLine.fromSdpLine);
|
|
8603
|
-
this.addParser('a', CandidateLine.fromSdpLine);
|
|
8604
|
-
this.addParser('a', SimulcastLine.fromSdpLine);
|
|
8605
|
-
this.addParser('a', SsrcLine.fromSdpLine);
|
|
8606
|
-
this.addParser('a', SsrcGroupLine.fromSdpLine);
|
|
8607
|
-
}
|
|
8608
|
-
}
|
|
8609
|
-
const DefaultSdpGrammar = new SdpGrammar();
|
|
8610
|
-
function isValidLine(line) {
|
|
8611
|
-
return line.length > 2;
|
|
8612
|
-
}
|
|
8613
|
-
function parseToModel(lines) {
|
|
8614
|
-
const sdp = new Sdp();
|
|
8615
|
-
let currBlock = sdp.session;
|
|
8616
|
-
lines.forEach((l) => {
|
|
8617
|
-
if (l instanceof MediaLine) {
|
|
8618
|
-
let mediaInfo;
|
|
8619
|
-
if (l.type === 'audio' || l.type === 'video') {
|
|
8620
|
-
mediaInfo = new AvMediaDescription(l);
|
|
8621
|
-
}
|
|
8622
|
-
else if (l.type === 'application') {
|
|
8623
|
-
mediaInfo = new ApplicationMediaDescription(l);
|
|
8624
|
-
}
|
|
8625
|
-
else {
|
|
8626
|
-
throw new Error(`Unhandled media type: ${l.type}`);
|
|
8627
|
-
}
|
|
8628
|
-
sdp.media.push(mediaInfo);
|
|
8629
|
-
currBlock = mediaInfo;
|
|
8630
|
-
}
|
|
8631
|
-
else {
|
|
8632
|
-
currBlock.addLine(l);
|
|
8633
|
-
}
|
|
8634
|
-
});
|
|
8635
|
-
return sdp;
|
|
8636
|
-
}
|
|
8637
|
-
function parseToLines(sdp, grammar) {
|
|
8638
|
-
const lines = [];
|
|
8639
|
-
sdp
|
|
8640
|
-
.split(/(\r\n|\r|\n)/)
|
|
8641
|
-
.filter(isValidLine)
|
|
8642
|
-
.forEach((l) => {
|
|
8643
|
-
const lineType = l[0];
|
|
8644
|
-
const lineValue = l.slice(2);
|
|
8645
|
-
const parsers = grammar.getParsers(lineType);
|
|
8646
|
-
for (const parser of parsers) {
|
|
8647
|
-
const result = parser(lineValue);
|
|
8648
|
-
if (result) {
|
|
8649
|
-
lines.push(result);
|
|
8650
|
-
return;
|
|
8651
|
-
}
|
|
8652
|
-
}
|
|
8653
|
-
const result = UnknownLine.fromSdpLine(l);
|
|
8654
|
-
lines.push(result);
|
|
8655
|
-
});
|
|
8656
|
-
return lines;
|
|
8657
|
-
}
|
|
8658
|
-
function parse(sdp, grammar = DefaultSdpGrammar) {
|
|
8659
|
-
const lines = parseToLines(sdp, grammar);
|
|
8660
|
-
const parsed = parseToModel(lines);
|
|
8661
|
-
return parsed;
|
|
8662
|
-
}
|
|
8663
|
-
function removeCodec(sdpOrAv, codecName) {
|
|
8664
|
-
const mediaDescriptions = sdpOrAv instanceof Sdp ? sdpOrAv.avMedia : [sdpOrAv];
|
|
8665
|
-
mediaDescriptions.forEach((media) => {
|
|
8666
|
-
const codecInfos = [...media.codecs.entries()].filter(([, ci]) => { var _a; return ((_a = ci.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === codecName.toLowerCase(); });
|
|
8667
|
-
codecInfos.forEach(([pt]) => media.removePt(pt));
|
|
8668
|
-
});
|
|
8669
|
-
}
|
|
8670
|
-
function retainCodecs(sdpOrAv, allowedCodecNames) {
|
|
8671
|
-
const avMediaDescriptions = sdpOrAv instanceof Sdp ? sdpOrAv.avMedia : [sdpOrAv];
|
|
8672
|
-
const allowedLowerCase = allowedCodecNames.map((s) => s.toLowerCase());
|
|
8673
|
-
avMediaDescriptions
|
|
8674
|
-
.map((av) => {
|
|
8675
|
-
return [...av.codecs.values()].map((c) => c.name);
|
|
8676
|
-
})
|
|
8677
|
-
.flat()
|
|
8678
|
-
.filter((codecName) => !allowedLowerCase.includes(codecName.toLowerCase()))
|
|
8679
|
-
.forEach((unwantedCodec) => removeCodec(sdpOrAv, unwantedCodec));
|
|
8680
|
-
}
|
|
8681
|
-
function retainCandidates(sdpOrMedia, allowedTransportTypes) {
|
|
8682
|
-
const mediaDescriptions = sdpOrMedia instanceof Sdp ? sdpOrMedia.media : [sdpOrMedia];
|
|
8683
|
-
let filtered = false;
|
|
8684
|
-
mediaDescriptions.forEach((media) => {
|
|
8685
|
-
media.iceInfo.candidates = media.iceInfo.candidates.filter((candidate) => {
|
|
8686
|
-
if (allowedTransportTypes.includes(candidate.transport.toLowerCase())) {
|
|
8687
|
-
return true;
|
|
8688
|
-
}
|
|
8689
|
-
filtered = true;
|
|
8690
|
-
return false;
|
|
8691
|
-
});
|
|
8692
|
-
});
|
|
8693
|
-
return filtered;
|
|
8694
|
-
}
|
|
8695
|
-
|
|
8696
|
-
function hasCodec(codecName, mLine) {
|
|
8697
|
-
return [...mLine.codecs.values()].some((ci) => { var _a; return ((_a = ci.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === codecName.toLowerCase(); });
|
|
8698
|
-
}
|
|
8699
|
-
|
|
8700
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
8701
|
-
|
|
8702
|
-
function getDefaultExportFromCjs (x) {
|
|
8703
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
8704
|
-
}
|
|
8705
|
-
|
|
8706
|
-
var es5 = {exports: {}};
|
|
8707
|
-
|
|
8708
|
-
(function (module, exports) {
|
|
8709
|
-
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return "NT";case"XP":return "XP";case"NT 5.0":return "2000";case"NT 5.1":return "XP";case"NT 5.2":return "2003";case"NT 6.0":return "Vista";case"NT 6.1":return "7";case"NT 6.2":return "8";case"NT 6.3":return "8.1";case"NT 10.0":return "10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return "Leopard";case 6:return "Snow Leopard";case 7:return "Lion";case 8:return "Mountain Lion";case 9:return "Mavericks";case 10:return "Yosemite";case 11:return "El Capitan";case 12:return "Sierra";case 13:return "High Sierra";case 14:return "Mojave";case 15:return "Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),a=Math.max(i,s),o=0,u=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(o=a-Math.min(i,s)),a-=1;a>=o;){if(u[0][a]>u[1][a])return 1;if(u[0][a]===u[1][a]){if(a===o)return 0;a-=1;}else if(u[0][a]<u[1][a])return -1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var o=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t];}));};for(t=0,r=s.length;t<r;t+=1)o();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default;},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0;t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"};t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"};t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"};t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"};t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}var o=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&a(t.prototype,r),n&&a(t,n),e}();t.default=o,e.exports=t.default;},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=u(r(92)),i=u(r(93)),s=u(r(94)),a=u(r(95)),o=u(r(17));function u(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse();}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=o.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=o.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=o.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=o.default.find(a.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return o.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var a=e[t];"string"==typeof a?(i[t]=a,s+=1):"object"==typeof a&&(r[t]=a,n+=1);})),n>0){var a=Object.keys(r),u=o.default.find(a,(function(e){return t.isOS(e)}));if(u){var d=this.satisfies(r[u]);if(void 0!==d)return d}var c=o.default.find(a,(function(e){return t.isPlatform(e)}));if(c){var f=this.satisfies(r[c]);if(void 0!==f)return f}}if(s>0){var l=Object.keys(i),h=o.default.find(l,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=o.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return ">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(o.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default;},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n};var s=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return {name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default;},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return {name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return {name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return {name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return {name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return {name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return {name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default;},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:[/googlebot/i],describe:function(){return {type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return {type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "blackberry"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return "bada"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "windows phone"===e.getBrowserName()},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return "android"===e.getOSName(!0)&&t>=3},describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return "android"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "macos"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return "windows"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "linux"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "playstation 4"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}},{test:function(e){return "roku"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default;},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:function(e){return "microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return {name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return {name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return {name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default;}})}));
|
|
8710
|
-
}(es5));
|
|
8711
|
-
|
|
8712
|
-
var Bowser = /*@__PURE__*/getDefaultExportFromCjs(es5.exports);
|
|
8713
|
-
|
|
8714
|
-
var BrowserName;
|
|
8715
|
-
(function (BrowserName) {
|
|
8716
|
-
BrowserName["CHROME"] = "Chrome";
|
|
8717
|
-
BrowserName["FIREFOX"] = "Firefox";
|
|
8718
|
-
BrowserName["EDGE"] = "Microsoft Edge";
|
|
8719
|
-
BrowserName["SAFARI"] = "Safari";
|
|
8720
|
-
})(BrowserName || (BrowserName = {}));
|
|
8721
|
-
class BrowserInfo {
|
|
8722
|
-
static getBrowserDetails() {
|
|
8723
|
-
return this.browser.getBrowser();
|
|
8724
|
-
}
|
|
8725
|
-
static getOSDetails() {
|
|
8726
|
-
return this.browser.getOS();
|
|
8727
|
-
}
|
|
8728
|
-
static getPlatformDetails() {
|
|
8729
|
-
return this.browser.getPlatform();
|
|
8730
|
-
}
|
|
8731
|
-
static getEngineDetails() {
|
|
8732
|
-
return this.browser.getEngine();
|
|
8733
|
-
}
|
|
8734
|
-
static isChrome() {
|
|
8735
|
-
return this.browser.getBrowserName() === BrowserName.CHROME;
|
|
8736
|
-
}
|
|
8737
|
-
static isFirefox() {
|
|
8738
|
-
return this.browser.getBrowserName() === BrowserName.FIREFOX;
|
|
8739
|
-
}
|
|
8740
|
-
static isEdge() {
|
|
8741
|
-
return this.browser.getBrowserName() === BrowserName.EDGE;
|
|
8742
|
-
}
|
|
8743
|
-
static isSafari() {
|
|
8744
|
-
return this.browser.getBrowserName() === BrowserName.SAFARI;
|
|
8745
|
-
}
|
|
8746
|
-
static isVersionGreaterThan(version) {
|
|
8747
|
-
const browserName = this.browser.getBrowserName();
|
|
8748
|
-
const checkTree = { [browserName]: `>${version}` };
|
|
8749
|
-
return this.browser.satisfies(checkTree);
|
|
8750
|
-
}
|
|
8751
|
-
static isVersionGreaterThanOrEqualTo(version) {
|
|
8752
|
-
const browserName = this.browser.getBrowserName();
|
|
8753
|
-
const checkTree = { [browserName]: `>=${version}` };
|
|
8754
|
-
return this.browser.satisfies(checkTree);
|
|
8755
|
-
}
|
|
8756
|
-
static isVersionLessThan(version) {
|
|
8757
|
-
const browserName = this.browser.getBrowserName();
|
|
8758
|
-
const checkTree = { [browserName]: `<${version}` };
|
|
8759
|
-
return this.browser.satisfies(checkTree);
|
|
8760
|
-
}
|
|
8761
|
-
static isVersionLessThanOrEqualTo(version) {
|
|
8762
|
-
const browserName = this.browser.getBrowserName();
|
|
8763
|
-
const checkTree = { [browserName]: `<=${version}` };
|
|
8764
|
-
return this.browser.satisfies(checkTree);
|
|
8765
|
-
}
|
|
8766
|
-
static isSubVersionOf(version) {
|
|
8767
|
-
const browserName = this.browser.getBrowserName();
|
|
8768
|
-
const checkTree = { [browserName]: `~${version}` };
|
|
8769
|
-
return this.browser.satisfies(checkTree);
|
|
8770
|
-
}
|
|
8771
|
-
}
|
|
8772
|
-
BrowserInfo.browser = Bowser.getParser(window.navigator.userAgent);
|
|
8773
|
-
|
|
8774
|
-
function getCpuInfo() {
|
|
8775
|
-
const cpuInfo = {};
|
|
8776
|
-
if (navigator.hardwareConcurrency) {
|
|
8777
|
-
cpuInfo.numLogicalCores = navigator.hardwareConcurrency;
|
|
8778
|
-
}
|
|
8779
|
-
return cpuInfo;
|
|
8780
|
-
}
|
|
8781
|
-
|
|
8782
|
-
var CapabilityState;
|
|
8783
|
-
(function (CapabilityState) {
|
|
8784
|
-
CapabilityState["NOT_CAPABLE"] = "not capable";
|
|
8785
|
-
CapabilityState["CAPABLE"] = "capable";
|
|
8786
|
-
CapabilityState["UNKNOWN"] = "unknown";
|
|
8787
|
-
})(CapabilityState || (CapabilityState = {}));
|
|
8788
|
-
getCpuInfo();
|
|
8789
|
-
|
|
8790
|
-
const simulcastMaxFrameSizes = {
|
|
8791
|
-
0: '240',
|
|
8792
|
-
1: '2304',
|
|
8793
|
-
2: '8160',
|
|
8794
|
-
};
|
|
8795
|
-
|
|
8796
|
-
var logger$1 = {exports: {}};
|
|
8797
|
-
|
|
8798
|
-
/*!
|
|
8799
|
-
* js-logger - http://github.com/jonnyreeves/js-logger
|
|
8800
|
-
* Jonny Reeves, http://jonnyreeves.co.uk/
|
|
8801
|
-
* js-logger may be freely distributed under the MIT license.
|
|
8802
|
-
*/
|
|
8803
|
-
|
|
8804
|
-
(function (module) {
|
|
8805
|
-
(function (global) {
|
|
8806
|
-
|
|
8807
|
-
// Top level module for the global, static logger instance.
|
|
8808
|
-
var Logger = { };
|
|
8809
|
-
|
|
8810
|
-
// For those that are at home that are keeping score.
|
|
8811
|
-
Logger.VERSION = "1.6.1";
|
|
6882
|
+
// For those that are at home that are keeping score.
|
|
6883
|
+
Logger.VERSION = "1.6.1";
|
|
8812
6884
|
|
|
8813
6885
|
// Function which handles all incoming log messages.
|
|
8814
6886
|
var logHandler;
|
|
@@ -9075,25 +7147,2026 @@ var logger$1 = {exports: {}};
|
|
|
9075
7147
|
}(commonjsGlobal$1));
|
|
9076
7148
|
}(logger$1));
|
|
9077
7149
|
|
|
9078
|
-
var Logger = logger$1.exports;
|
|
7150
|
+
var Logger = logger$1.exports;
|
|
7151
|
+
|
|
7152
|
+
var WcmeErrorType;
|
|
7153
|
+
(function (WcmeErrorType) {
|
|
7154
|
+
WcmeErrorType["CREATE_OFFER_FAILED"] = "CREATE_OFFER_FAILED";
|
|
7155
|
+
WcmeErrorType["SET_ANSWER_FAILED"] = "SET_ANSWER_FAILED";
|
|
7156
|
+
WcmeErrorType["OFFER_ANSWER_MISMATCH"] = "OFFER_ANSWER_MISMATCH";
|
|
7157
|
+
WcmeErrorType["SDP_MUNGE_FAILED"] = "SDP_MUNGE_FAILED";
|
|
7158
|
+
WcmeErrorType["SDP_MUNGE_MISSING_CODECS"] = "SDP_MUNGE_MISSING_CODECS";
|
|
7159
|
+
WcmeErrorType["INVALID_STREAM_REQUEST"] = "INVALID_STREAM_REQUEST";
|
|
7160
|
+
WcmeErrorType["GET_TRANSCEIVER_FAILED"] = "GET_TRANSCEIVER_FAILED";
|
|
7161
|
+
WcmeErrorType["GET_MAX_BITRATE_FAILED"] = "GET_MAX_BITRATE_FAILED";
|
|
7162
|
+
WcmeErrorType["GET_PAYLOAD_TYPE_FAILED"] = "GET_PAYLOAD_TYPE_FAILED";
|
|
7163
|
+
WcmeErrorType["SET_NMG_FAILED"] = "SET_NMG_FAILED";
|
|
7164
|
+
})(WcmeErrorType || (WcmeErrorType = {}));
|
|
7165
|
+
class WcmeError {
|
|
7166
|
+
constructor(type, message = '') {
|
|
7167
|
+
this.type = type;
|
|
7168
|
+
this.message = message;
|
|
7169
|
+
}
|
|
7170
|
+
}
|
|
7171
|
+
|
|
7172
|
+
const DEFAULT_LOGGER_NAME = 'web-client-media-engine';
|
|
7173
|
+
const logger = Logger.get(DEFAULT_LOGGER_NAME);
|
|
7174
|
+
logger.setLevel(Logger.DEBUG);
|
|
7175
|
+
function setLogLevel(level) {
|
|
7176
|
+
logger.setLevel(level);
|
|
7177
|
+
Logger$1.setLevel(level);
|
|
7178
|
+
Logger$2.setLevel(level);
|
|
7179
|
+
}
|
|
7180
|
+
function getLogLevel() {
|
|
7181
|
+
return logger.getLevel();
|
|
7182
|
+
}
|
|
7183
|
+
function logErrorAndThrow(errorType, message) {
|
|
7184
|
+
logger.error(message);
|
|
7185
|
+
throw new WcmeError(errorType, message);
|
|
7186
|
+
}
|
|
7187
|
+
function setLogHandler(logHandler) {
|
|
7188
|
+
Logger.setHandler(logHandler);
|
|
7189
|
+
Logger$1.setHandler(logHandler);
|
|
7190
|
+
Logger$2.setHandler(logHandler);
|
|
7191
|
+
}
|
|
7192
|
+
|
|
7193
|
+
var MediaCodecMimeType;
|
|
7194
|
+
(function (MediaCodecMimeType) {
|
|
7195
|
+
MediaCodecMimeType["H264"] = "video/H264";
|
|
7196
|
+
MediaCodecMimeType["AV1"] = "video/AV1";
|
|
7197
|
+
MediaCodecMimeType["OPUS"] = "audio/opus";
|
|
7198
|
+
})(MediaCodecMimeType || (MediaCodecMimeType = {}));
|
|
7199
|
+
const defaultMaxVideoEncodeFrameSize = 8160;
|
|
7200
|
+
const defaultMaxVideoEncodeMbps = 244800;
|
|
7201
|
+
var RecommendedOpusBitrates;
|
|
7202
|
+
(function (RecommendedOpusBitrates) {
|
|
7203
|
+
RecommendedOpusBitrates[RecommendedOpusBitrates["NB"] = 12000] = "NB";
|
|
7204
|
+
RecommendedOpusBitrates[RecommendedOpusBitrates["WB"] = 20000] = "WB";
|
|
7205
|
+
RecommendedOpusBitrates[RecommendedOpusBitrates["FB"] = 40000] = "FB";
|
|
7206
|
+
RecommendedOpusBitrates[RecommendedOpusBitrates["FB_MONO_MUSIC"] = 64000] = "FB_MONO_MUSIC";
|
|
7207
|
+
RecommendedOpusBitrates[RecommendedOpusBitrates["FB_STEREO_MUSIC"] = 128000] = "FB_STEREO_MUSIC";
|
|
7208
|
+
})(RecommendedOpusBitrates || (RecommendedOpusBitrates = {}));
|
|
7209
|
+
const maxFrameSizeToMaxBitrateMap = new Map([
|
|
7210
|
+
[60, 99000],
|
|
7211
|
+
[240, 199000],
|
|
7212
|
+
[576, 300000],
|
|
7213
|
+
[920, 640000],
|
|
7214
|
+
[1296, 720000],
|
|
7215
|
+
[2304, 880000],
|
|
7216
|
+
[3600, 2500000],
|
|
7217
|
+
[8160, 4000000],
|
|
7218
|
+
]);
|
|
7219
|
+
function areProfileLevelIdsCompatible(senderProfileLevelId, receiverProfileLevelId, levelAsymmetryAllowed) {
|
|
7220
|
+
const senderProfile = Number.parseInt(`0x${senderProfileLevelId}`, 16);
|
|
7221
|
+
const recvProfile = Number.parseInt(`0x${receiverProfileLevelId}`, 16);
|
|
7222
|
+
const senderProfileIdc = senderProfile >> 16;
|
|
7223
|
+
const recvProfileIdc = recvProfile >> 16;
|
|
7224
|
+
const senderProfileIop = (senderProfile & 0x00ff00) >> 8;
|
|
7225
|
+
const recvProfileIop = (recvProfile & 0x00ff00) >> 8;
|
|
7226
|
+
const senderLevelIdc = senderProfile & 0x0000ff;
|
|
7227
|
+
const recvLevelIdc = recvProfile & 0x0000ff;
|
|
7228
|
+
const areProfileCompatible = (senderProfileIdc === recvProfileIdc && senderProfileIop === recvProfileIop) ||
|
|
7229
|
+
(senderProfileIdc === 0x42 &&
|
|
7230
|
+
recvProfileIdc === 0x42 &&
|
|
7231
|
+
(senderProfileIop & 0x40) === (recvProfileIop & 0x40));
|
|
7232
|
+
const isLevelIdcCompatible = levelAsymmetryAllowed
|
|
7233
|
+
? true
|
|
7234
|
+
: senderLevelIdc <= recvLevelIdc;
|
|
7235
|
+
return areProfileCompatible && isLevelIdcCompatible;
|
|
7236
|
+
}
|
|
7237
|
+
function areCodecsCompatible(senderCodec, receiverCodec) {
|
|
7238
|
+
return Object.keys(receiverCodec).every((key) => {
|
|
7239
|
+
if (key === 'clockRate' || key === 'name') {
|
|
7240
|
+
return senderCodec[key] === receiverCodec[key];
|
|
7241
|
+
}
|
|
7242
|
+
if (key === 'fmtParams') {
|
|
7243
|
+
const fmtpForSender = senderCodec[key];
|
|
7244
|
+
const fmtpForReceiver = receiverCodec[key];
|
|
7245
|
+
const levelAsymmetryAllowed = [...fmtpForSender.keys()].some((senderFmtpParamKey) => {
|
|
7246
|
+
return (senderFmtpParamKey === 'level-asymmetry-allowed' &&
|
|
7247
|
+
fmtpForReceiver.get(senderFmtpParamKey) === '1' &&
|
|
7248
|
+
fmtpForSender.get(senderFmtpParamKey) === '1');
|
|
7249
|
+
});
|
|
7250
|
+
return [...fmtpForSender.keys()].every((senderFmtpParamKey) => {
|
|
7251
|
+
if (fmtpForReceiver.get(senderFmtpParamKey)) {
|
|
7252
|
+
if (senderFmtpParamKey === 'profile-level-id') {
|
|
7253
|
+
return areProfileLevelIdsCompatible(fmtpForSender.get(senderFmtpParamKey), fmtpForReceiver.get(senderFmtpParamKey), levelAsymmetryAllowed);
|
|
7254
|
+
}
|
|
7255
|
+
}
|
|
7256
|
+
if (senderFmtpParamKey === 'packetization-mode') {
|
|
7257
|
+
return fmtpForSender.get(senderFmtpParamKey) === fmtpForReceiver.get(senderFmtpParamKey);
|
|
7258
|
+
}
|
|
7259
|
+
return true;
|
|
7260
|
+
});
|
|
7261
|
+
}
|
|
7262
|
+
return true;
|
|
7263
|
+
});
|
|
7264
|
+
}
|
|
7265
|
+
function gcd(a, b) {
|
|
7266
|
+
return b === 0 ? a : gcd(b, a % b);
|
|
7267
|
+
}
|
|
7268
|
+
function getFrameHeightByMaxFs(sourceAspectRatio, requestedMaxFs) {
|
|
7269
|
+
const _gcd = gcd(sourceAspectRatio[0], sourceAspectRatio[1]);
|
|
7270
|
+
const minNumberRatiosForWidth = sourceAspectRatio[0] / _gcd;
|
|
7271
|
+
const minNumberRatiosForHeight = sourceAspectRatio[1] / _gcd;
|
|
7272
|
+
return (Math.floor(Math.sqrt((requestedMaxFs * 16 * 16) / (minNumberRatiosForWidth * minNumberRatiosForHeight))) * minNumberRatiosForHeight);
|
|
7273
|
+
}
|
|
7274
|
+
function getScaleDownRatio(sourceWidth, sourceHeight, maxFs, maxWidth, maxHeight) {
|
|
7275
|
+
if (!sourceWidth || !sourceHeight || !maxFs) {
|
|
7276
|
+
return undefined;
|
|
7277
|
+
}
|
|
7278
|
+
let scaleDownRatio = Math.max(sourceHeight / getFrameHeightByMaxFs([sourceWidth, sourceHeight], maxFs), 1.0);
|
|
7279
|
+
if (maxWidth && maxHeight) {
|
|
7280
|
+
scaleDownRatio = Math.max(sourceWidth / maxWidth, sourceHeight / maxHeight, scaleDownRatio);
|
|
7281
|
+
}
|
|
7282
|
+
return scaleDownRatio;
|
|
7283
|
+
}
|
|
7284
|
+
function getRecommendedMaxBitrateForFrameSize(requestedMaxFs) {
|
|
7285
|
+
if (requestedMaxFs < 60) {
|
|
7286
|
+
logErrorAndThrow(WcmeErrorType.GET_MAX_BITRATE_FAILED, `Requested max video frame size cannot be less than 60.`);
|
|
7287
|
+
}
|
|
7288
|
+
const expectedHeight = [...maxFrameSizeToMaxBitrateMap.keys()]
|
|
7289
|
+
.sort((a, b) => b - a)
|
|
7290
|
+
.find((h) => requestedMaxFs >= h);
|
|
7291
|
+
return maxFrameSizeToMaxBitrateMap.get(expectedHeight);
|
|
7292
|
+
}
|
|
7293
|
+
|
|
7294
|
+
/******************************************************************************
|
|
7295
|
+
Copyright (c) Microsoft Corporation.
|
|
7296
|
+
|
|
7297
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7298
|
+
purpose with or without fee is hereby granted.
|
|
7299
|
+
|
|
7300
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
7301
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
7302
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
7303
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
7304
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
7305
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
7306
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
7307
|
+
***************************************************************************** */
|
|
7308
|
+
|
|
7309
|
+
function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
7310
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7311
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7312
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7313
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7314
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7315
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
7316
|
+
});
|
|
7317
|
+
}
|
|
7318
|
+
|
|
7319
|
+
var __awaiter = (commonjsGlobal$1 && commonjsGlobal$1.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7320
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7321
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7322
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7323
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7324
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7325
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
7326
|
+
});
|
|
7327
|
+
};
|
|
7328
|
+
var __generator = (commonjsGlobal$1 && commonjsGlobal$1.__generator) || function (thisArg, body) {
|
|
7329
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
7330
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
7331
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
7332
|
+
function step(op) {
|
|
7333
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
7334
|
+
while (_) try {
|
|
7335
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
7336
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
7337
|
+
switch (op[0]) {
|
|
7338
|
+
case 0: case 1: t = op; break;
|
|
7339
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
7340
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
7341
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
7342
|
+
default:
|
|
7343
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
7344
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
7345
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
7346
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
7347
|
+
if (t[2]) _.ops.pop();
|
|
7348
|
+
_.trys.pop(); continue;
|
|
7349
|
+
}
|
|
7350
|
+
op = body.call(thisArg, _);
|
|
7351
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
7352
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7353
|
+
}
|
|
7354
|
+
};
|
|
7355
|
+
var rtcStats_1 = void 0;
|
|
7356
|
+
/**
|
|
7357
|
+
* Copies values of any nested depth.
|
|
7358
|
+
*
|
|
7359
|
+
* @param value - The value to be copied.
|
|
7360
|
+
* @returns - Copied value.
|
|
7361
|
+
*/
|
|
7362
|
+
var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
|
|
7363
|
+
/**
|
|
7364
|
+
* Check deep equality between two values.
|
|
7365
|
+
*
|
|
7366
|
+
* @param value1 - First value to check.
|
|
7367
|
+
* @param value2 - Second value to check.
|
|
7368
|
+
* @returns True if values are deeply equal, false otherwise.
|
|
7369
|
+
*/
|
|
7370
|
+
var deepEqual = function (value1, value2) {
|
|
7371
|
+
// If both immutable values are equal, return true.
|
|
7372
|
+
if (value1 === value2) {
|
|
7373
|
+
return true;
|
|
7374
|
+
}
|
|
7375
|
+
// If both are objects, we check the length and properties of each.
|
|
7376
|
+
if (value1 && value2 && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
7377
|
+
if (value1.constructor !== value2.constructor)
|
|
7378
|
+
return false;
|
|
7379
|
+
// Return false if the objects are of different sizes.
|
|
7380
|
+
if (Object.keys(value1).length !== Object.keys(value2).length) {
|
|
7381
|
+
return false;
|
|
7382
|
+
}
|
|
7383
|
+
// Deep equal check each property in the object, returns true if we found no
|
|
7384
|
+
// differing properties.
|
|
7385
|
+
return Object.keys(value1).reduce(function (val, prop) {
|
|
7386
|
+
if (value2[prop]) {
|
|
7387
|
+
if (!deepEqual(value1[prop], value2[prop])) {
|
|
7388
|
+
return false;
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
else {
|
|
7392
|
+
return false;
|
|
7393
|
+
}
|
|
7394
|
+
return val;
|
|
7395
|
+
}, true);
|
|
7396
|
+
}
|
|
7397
|
+
// Return false if no other conditions are met.
|
|
7398
|
+
return false;
|
|
7399
|
+
};
|
|
7400
|
+
/**
|
|
7401
|
+
* Translates a Map into an object.
|
|
7402
|
+
*
|
|
7403
|
+
* @param report - The report in Map form.
|
|
7404
|
+
* @returns - A deduped object.
|
|
7405
|
+
*/
|
|
7406
|
+
var map2obj = function (report) {
|
|
7407
|
+
if (!report.size) {
|
|
7408
|
+
return report;
|
|
7409
|
+
}
|
|
7410
|
+
var o = {};
|
|
7411
|
+
report.forEach(function (value, key) {
|
|
7412
|
+
o[key] = value;
|
|
7413
|
+
});
|
|
7414
|
+
return o;
|
|
7415
|
+
};
|
|
7416
|
+
var dumpStream = function (stream) { return ({
|
|
7417
|
+
id: stream.id,
|
|
7418
|
+
tracks: stream.getTracks().map(function (track) { return ({
|
|
7419
|
+
id: track.id,
|
|
7420
|
+
kind: track.kind,
|
|
7421
|
+
label: track.label,
|
|
7422
|
+
enabled: track.enabled,
|
|
7423
|
+
muted: track.muted,
|
|
7424
|
+
readyState: track.readyState
|
|
7425
|
+
}); })
|
|
7426
|
+
}); };
|
|
7427
|
+
var persistedKeys = ['type', 'id', 'timestamp'];
|
|
7428
|
+
/**
|
|
7429
|
+
* Check to see if the report consists of more than just the persisted metadata.
|
|
7430
|
+
*
|
|
7431
|
+
* @param report - The report line being checked.
|
|
7432
|
+
* @returns True if the report item contains non-persisted keys, false otherwise.
|
|
7433
|
+
*/
|
|
7434
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7435
|
+
var hasNonMetadata = function (report) {
|
|
7436
|
+
return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
|
|
7437
|
+
};
|
|
7438
|
+
/**
|
|
7439
|
+
* Apply a delta compression to the stats report. Reduces size by ~90%.
|
|
7440
|
+
* To reduce further, report keys could be compressed.
|
|
7441
|
+
*
|
|
7442
|
+
* @param oldStats - Previous report items that we dedupe against.
|
|
7443
|
+
* @param newStats - New incoming stats.
|
|
7444
|
+
* @returns - Compressed Stats.
|
|
7445
|
+
*/
|
|
7446
|
+
var deltaCompression = function (oldStats, newStats) {
|
|
7447
|
+
var updatedStats = deepCopy$1(newStats);
|
|
7448
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
7449
|
+
var report = updatedStats[id];
|
|
7450
|
+
if (!oldStats[id]) {
|
|
7451
|
+
return;
|
|
7452
|
+
}
|
|
7453
|
+
// Persist specific values beyond delta compression, as long as they
|
|
7454
|
+
// aren't the only non-deduped keys.
|
|
7455
|
+
Object.keys(report).forEach(function (name) {
|
|
7456
|
+
if (deepEqual(report[name], oldStats[id][name]) && !persistedKeys.includes(name)) {
|
|
7457
|
+
delete updatedStats[id][name];
|
|
7458
|
+
}
|
|
7459
|
+
if (!hasNonMetadata(report)) {
|
|
7460
|
+
delete updatedStats[id];
|
|
7461
|
+
}
|
|
7462
|
+
});
|
|
7463
|
+
});
|
|
7464
|
+
// Use the most recent timestamp.
|
|
7465
|
+
var timestamp = -Infinity;
|
|
7466
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
7467
|
+
var report = updatedStats[id];
|
|
7468
|
+
if (report.timestamp > timestamp) {
|
|
7469
|
+
timestamp = report.timestamp;
|
|
7470
|
+
}
|
|
7471
|
+
});
|
|
7472
|
+
// Delete the timestamps on each item.
|
|
7473
|
+
Object.keys(updatedStats).forEach(function (id) {
|
|
7474
|
+
var report = updatedStats[id];
|
|
7475
|
+
if (report.timestamp === timestamp) {
|
|
7476
|
+
delete report.timestamp;
|
|
7477
|
+
}
|
|
7478
|
+
});
|
|
7479
|
+
updatedStats.timestamp = timestamp;
|
|
7480
|
+
return updatedStats;
|
|
7481
|
+
};
|
|
7482
|
+
/**
|
|
7483
|
+
* Format the stats report into an array.
|
|
7484
|
+
*
|
|
7485
|
+
* @param report - A WebRTC stats report.
|
|
7486
|
+
* @returns - An array of Stats Report items.
|
|
7487
|
+
*/
|
|
7488
|
+
var formatStatsReport = function (report) {
|
|
7489
|
+
return Object.keys(report)
|
|
7490
|
+
.filter(function (name) { return name !== 'timestamp'; })
|
|
7491
|
+
.map(function (name) { return JSON.stringify(report[name]); });
|
|
7492
|
+
};
|
|
7493
|
+
/**
|
|
7494
|
+
* Parametrize a single string event to contain type and an (empty) id.
|
|
7495
|
+
*
|
|
7496
|
+
* @param value - The value to parametrize.
|
|
7497
|
+
* @returns An event object.
|
|
7498
|
+
*/
|
|
7499
|
+
var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
|
|
7500
|
+
/**
|
|
7501
|
+
* Attach a Peer Connection to periodically get updated on events and stats.
|
|
7502
|
+
*
|
|
7503
|
+
* @param pc - Peer Connection in which we attach.
|
|
7504
|
+
* @param logger - Logging function to log events and stats.
|
|
7505
|
+
* @param intervalTime - Time between each `getStats` check.
|
|
7506
|
+
* @param statsPreProcessor - Optional function that modifies stats.
|
|
7507
|
+
*/
|
|
7508
|
+
var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
|
|
7509
|
+
if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
|
|
7510
|
+
var prev = {};
|
|
7511
|
+
/**
|
|
7512
|
+
* Log stats or event data with additional tracking information.
|
|
7513
|
+
*
|
|
7514
|
+
* @param name - Name of the event to log.
|
|
7515
|
+
* @param payload - Log data pertaining to the event.
|
|
7516
|
+
* @param timestamp - Time the event happened in milliseconds.
|
|
7517
|
+
*/
|
|
7518
|
+
var trace = function (name, payload, timestamp) {
|
|
7519
|
+
logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
|
|
7520
|
+
};
|
|
7521
|
+
var origPeerConnection = window.RTCPeerConnection;
|
|
7522
|
+
pc.addEventListener('icecandidate', function (e) {
|
|
7523
|
+
if (e.candidate) {
|
|
7524
|
+
trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
|
|
7525
|
+
}
|
|
7526
|
+
});
|
|
7527
|
+
pc.addEventListener('icecandidateerror', function (event) {
|
|
7528
|
+
var _a = event, errorCode = _a.errorCode, errorText = _a.errorText;
|
|
7529
|
+
trace('onicecandidateerror', makeEvent("".concat(errorCode, ": ").concat(errorText)));
|
|
7530
|
+
});
|
|
7531
|
+
pc.addEventListener('track', function (e) {
|
|
7532
|
+
trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
|
|
7533
|
+
.map(function (stream) { return "stream:".concat(stream.id); })
|
|
7534
|
+
.join(' '))));
|
|
7535
|
+
});
|
|
7536
|
+
pc.addEventListener('signalingstatechange', function () {
|
|
7537
|
+
trace('onsignalingstatechange', makeEvent(pc.signalingState));
|
|
7538
|
+
});
|
|
7539
|
+
pc.addEventListener('iceconnectionstatechange', function () {
|
|
7540
|
+
trace('oniceconnectionstatechange', makeEvent(pc.iceConnectionState));
|
|
7541
|
+
});
|
|
7542
|
+
pc.addEventListener('icegatheringstatechange', function () {
|
|
7543
|
+
trace('onicegatheringstatechange', makeEvent(pc.iceGatheringState));
|
|
7544
|
+
});
|
|
7545
|
+
pc.addEventListener('connectionstatechange', function () {
|
|
7546
|
+
trace('onconnectionstatechange', makeEvent(pc.connectionState));
|
|
7547
|
+
});
|
|
7548
|
+
pc.addEventListener('negotiationneeded', function () {
|
|
7549
|
+
trace('onnegotiationneeded', makeEvent('negotiationneeded'));
|
|
7550
|
+
});
|
|
7551
|
+
pc.addEventListener('datachannel', function (event) {
|
|
7552
|
+
trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
|
|
7553
|
+
});
|
|
7554
|
+
['createDataChannel', 'close'].forEach(function (method) {
|
|
7555
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7556
|
+
if (nativeMethod) {
|
|
7557
|
+
origPeerConnection.prototype[method] = function () {
|
|
7558
|
+
trace(method, makeEvent(method));
|
|
7559
|
+
return nativeMethod.apply(this, arguments);
|
|
7560
|
+
};
|
|
7561
|
+
}
|
|
7562
|
+
});
|
|
7563
|
+
['addStream', 'removeStream'].forEach(function (method) {
|
|
7564
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7565
|
+
if (nativeMethod) {
|
|
7566
|
+
origPeerConnection.prototype[method] = function () {
|
|
7567
|
+
var stream = arguments[0];
|
|
7568
|
+
var streamInfo = stream
|
|
7569
|
+
.getTracks()
|
|
7570
|
+
.map(function (t) { return "".concat(t.kind, ":").concat(t.id); })
|
|
7571
|
+
.join(',');
|
|
7572
|
+
trace(method, makeEvent("".concat(stream.id, " ").concat(streamInfo)));
|
|
7573
|
+
return nativeMethod.apply(this, arguments);
|
|
7574
|
+
};
|
|
7575
|
+
}
|
|
7576
|
+
});
|
|
7577
|
+
['addTrack'].forEach(function (method) {
|
|
7578
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7579
|
+
if (nativeMethod) {
|
|
7580
|
+
origPeerConnection.prototype[method] = function () {
|
|
7581
|
+
var track = arguments[0];
|
|
7582
|
+
var streams = [].slice.call(arguments, 1);
|
|
7583
|
+
trace(method, makeEvent("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) { return "stream:".concat(s.id); }).join(';') || '-')));
|
|
7584
|
+
return nativeMethod.apply(this, arguments);
|
|
7585
|
+
};
|
|
7586
|
+
}
|
|
7587
|
+
});
|
|
7588
|
+
['removeTrack'].forEach(function (method) {
|
|
7589
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7590
|
+
if (nativeMethod) {
|
|
7591
|
+
origPeerConnection.prototype[method] = function () {
|
|
7592
|
+
var track = arguments[0].track;
|
|
7593
|
+
trace(method, makeEvent(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
|
|
7594
|
+
return nativeMethod.apply(this, arguments);
|
|
7595
|
+
};
|
|
7596
|
+
}
|
|
7597
|
+
});
|
|
7598
|
+
['createOffer', 'createAnswer'].forEach(function (method) {
|
|
7599
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7600
|
+
if (nativeMethod) {
|
|
7601
|
+
origPeerConnection.prototype[method] = function () {
|
|
7602
|
+
var opts;
|
|
7603
|
+
var args = arguments;
|
|
7604
|
+
if (arguments.length === 1 && typeof arguments[0] === 'object') {
|
|
7605
|
+
// eslint-disable-next-line prefer-destructuring
|
|
7606
|
+
opts = arguments[0];
|
|
7607
|
+
}
|
|
7608
|
+
else if (arguments.length === 3 && typeof arguments[2] === 'object') {
|
|
7609
|
+
// eslint-disable-next-line prefer-destructuring
|
|
7610
|
+
opts = arguments[2];
|
|
7611
|
+
}
|
|
7612
|
+
trace(method, makeEvent(opts || ''));
|
|
7613
|
+
return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
|
|
7614
|
+
trace("".concat(method, "OnSuccess"), makeEvent(description.sdp));
|
|
7615
|
+
if (args.length > 0 && typeof args[0] === 'function') {
|
|
7616
|
+
args[0].apply(null, [description]);
|
|
7617
|
+
return undefined;
|
|
7618
|
+
}
|
|
7619
|
+
return description;
|
|
7620
|
+
}, function (err) {
|
|
7621
|
+
trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
|
|
7622
|
+
if (args.length > 1 && typeof args[1] === 'function') {
|
|
7623
|
+
args[1].apply(null, [err]);
|
|
7624
|
+
return;
|
|
7625
|
+
}
|
|
7626
|
+
throw err;
|
|
7627
|
+
});
|
|
7628
|
+
};
|
|
7629
|
+
}
|
|
7630
|
+
});
|
|
7631
|
+
['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
|
|
7632
|
+
var nativeMethod = origPeerConnection.prototype[method];
|
|
7633
|
+
if (nativeMethod) {
|
|
7634
|
+
origPeerConnection.prototype[method] = function () {
|
|
7635
|
+
var args = arguments;
|
|
7636
|
+
trace(method, makeEvent(method === 'addIceCandidate' ? arguments[0] : arguments[0].sdp));
|
|
7637
|
+
return nativeMethod.apply(this, [arguments[0]]).then(function () {
|
|
7638
|
+
trace("".concat(method, "OnSuccess"), makeEvent('success'));
|
|
7639
|
+
if (args.length >= 2 && typeof args[1] === 'function') {
|
|
7640
|
+
args[1].apply(null, []);
|
|
7641
|
+
return undefined;
|
|
7642
|
+
}
|
|
7643
|
+
return undefined;
|
|
7644
|
+
}, function (err) {
|
|
7645
|
+
trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
|
|
7646
|
+
if (args.length >= 3 && typeof args[2] === 'function') {
|
|
7647
|
+
args[2].apply(null, [err]);
|
|
7648
|
+
return undefined;
|
|
7649
|
+
}
|
|
7650
|
+
throw err;
|
|
7651
|
+
});
|
|
7652
|
+
};
|
|
7653
|
+
}
|
|
7654
|
+
});
|
|
7655
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
7656
|
+
var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
7657
|
+
var gum = function () {
|
|
7658
|
+
trace('navigator.mediaDevices.getUserMedia', makeEvent(JSON.stringify(arguments[0])));
|
|
7659
|
+
return origGetUserMedia_1
|
|
7660
|
+
.apply(navigator.mediaDevices, arguments)
|
|
7661
|
+
.then(function (stream) {
|
|
7662
|
+
trace('navigator.mediaDevices.getUserMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
|
|
7663
|
+
return stream;
|
|
7664
|
+
}, function (err) {
|
|
7665
|
+
trace('navigator.mediaDevices.getUserMediaOnFailure', makeEvent(err.name));
|
|
7666
|
+
return Promise.reject(err);
|
|
7667
|
+
});
|
|
7668
|
+
};
|
|
7669
|
+
navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
|
|
7670
|
+
}
|
|
7671
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
7672
|
+
var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
|
|
7673
|
+
var gdm = function () {
|
|
7674
|
+
trace('navigator.mediaDevices.getDisplayMedia', makeEvent(JSON.stringify(arguments[0])));
|
|
7675
|
+
return origGetDisplayMedia_1
|
|
7676
|
+
.apply(navigator.mediaDevices, arguments)
|
|
7677
|
+
.then(function (stream) {
|
|
7678
|
+
trace('navigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
|
|
7679
|
+
return stream;
|
|
7680
|
+
}, function (err) {
|
|
7681
|
+
trace('navigator.mediaDevices.getDisplayMediaOnFailure', makeEvent(err.name));
|
|
7682
|
+
return Promise.reject(err);
|
|
7683
|
+
});
|
|
7684
|
+
};
|
|
7685
|
+
navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
|
|
7686
|
+
}
|
|
7687
|
+
var getStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7688
|
+
return __generator(this, function (_a) {
|
|
7689
|
+
return [2 /*return*/, pc.getStats(null).then(function (res) {
|
|
7690
|
+
// Convert from stats report to js Map in order to have values set in `statsPreProcessor`
|
|
7691
|
+
var statsMap = new Map();
|
|
7692
|
+
res.forEach(function (stats, key) { return statsMap.set(key, stats); });
|
|
7693
|
+
return statsPreProcessor(statsMap).then(function () {
|
|
7694
|
+
var now = map2obj(statsMap);
|
|
7695
|
+
var base = deepCopy$1(now); // our new prev
|
|
7696
|
+
var compressed = deltaCompression(prev, now);
|
|
7697
|
+
trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
|
|
7698
|
+
prev = base;
|
|
7699
|
+
return Promise.resolve();
|
|
7700
|
+
});
|
|
7701
|
+
})];
|
|
7702
|
+
});
|
|
7703
|
+
}); };
|
|
7704
|
+
var interval = window.setInterval(function () {
|
|
7705
|
+
if (pc.signalingState === 'closed') {
|
|
7706
|
+
window.clearInterval(interval);
|
|
7707
|
+
return;
|
|
7708
|
+
}
|
|
7709
|
+
getStatsReport();
|
|
7710
|
+
}, intervalTime);
|
|
7711
|
+
var forceStatsReport = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
7712
|
+
return __generator(this, function (_a) {
|
|
7713
|
+
return [2 /*return*/, getStatsReport()];
|
|
7714
|
+
});
|
|
7715
|
+
}); };
|
|
7716
|
+
return { forceStatsReport: forceStatsReport };
|
|
7717
|
+
};
|
|
7718
|
+
rtcStats_1 = rtcStats;
|
|
7719
|
+
|
|
7720
|
+
const NUM = '\\d+';
|
|
7721
|
+
const SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
|
|
7722
|
+
const ANY_NON_WS = '\\S+';
|
|
7723
|
+
const SP = '\\s';
|
|
7724
|
+
const REST = '.+';
|
|
7725
|
+
|
|
7726
|
+
class Line {
|
|
7727
|
+
}
|
|
7728
|
+
|
|
7729
|
+
var _a$5;
|
|
7730
|
+
class BandwidthLine extends Line {
|
|
7731
|
+
constructor(bandwidthType, bandwidth) {
|
|
7732
|
+
super();
|
|
7733
|
+
this.bandwidthType = bandwidthType;
|
|
7734
|
+
this.bandwidth = bandwidth;
|
|
7735
|
+
}
|
|
7736
|
+
static fromSdpLine(line) {
|
|
7737
|
+
if (!BandwidthLine.regex.test(line)) {
|
|
7738
|
+
return undefined;
|
|
7739
|
+
}
|
|
7740
|
+
const tokens = line.match(BandwidthLine.regex);
|
|
7741
|
+
const bandwidthType = tokens[1];
|
|
7742
|
+
const bandwidth = parseInt(tokens[2], 10);
|
|
7743
|
+
return new BandwidthLine(bandwidthType, bandwidth);
|
|
7744
|
+
}
|
|
7745
|
+
toSdpLine() {
|
|
7746
|
+
return `b=${this.bandwidthType}:${this.bandwidth}`;
|
|
7747
|
+
}
|
|
7748
|
+
}
|
|
7749
|
+
_a$5 = BandwidthLine;
|
|
7750
|
+
BandwidthLine.BW_TYPE_REGEX = 'CT|AS|TIAS';
|
|
7751
|
+
BandwidthLine.regex = new RegExp(`^(${_a$5.BW_TYPE_REGEX}):(${NUM})`);
|
|
7752
|
+
|
|
7753
|
+
class BundleGroupLine extends Line {
|
|
7754
|
+
constructor(mids) {
|
|
7755
|
+
super();
|
|
7756
|
+
this.mids = mids;
|
|
7757
|
+
}
|
|
7758
|
+
static fromSdpLine(line) {
|
|
7759
|
+
if (!BundleGroupLine.regex.test(line)) {
|
|
7760
|
+
return undefined;
|
|
7761
|
+
}
|
|
7762
|
+
const tokens = line.match(BundleGroupLine.regex);
|
|
7763
|
+
const mids = tokens[1].split(' ');
|
|
7764
|
+
return new BundleGroupLine(mids);
|
|
7765
|
+
}
|
|
7766
|
+
toSdpLine() {
|
|
7767
|
+
return `a=group:BUNDLE ${this.mids.join(' ')}`;
|
|
7768
|
+
}
|
|
7769
|
+
}
|
|
7770
|
+
BundleGroupLine.regex = new RegExp(`^group:BUNDLE (${REST})`);
|
|
7771
|
+
|
|
7772
|
+
var _a$4;
|
|
7773
|
+
class CandidateLine extends Line {
|
|
7774
|
+
constructor(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions) {
|
|
7775
|
+
super();
|
|
7776
|
+
this.foundation = foundation;
|
|
7777
|
+
this.componentId = componentId;
|
|
7778
|
+
this.transport = transport;
|
|
7779
|
+
this.priority = priority;
|
|
7780
|
+
this.connectionAddress = connectionAddress;
|
|
7781
|
+
this.port = port;
|
|
7782
|
+
this.candidateType = candidateType;
|
|
7783
|
+
this.relAddr = relAddr;
|
|
7784
|
+
this.relPort = relPort;
|
|
7785
|
+
this.candidateExtensions = candidateExtensions;
|
|
7786
|
+
}
|
|
7787
|
+
static fromSdpLine(line) {
|
|
7788
|
+
if (!CandidateLine.regex.test(line)) {
|
|
7789
|
+
return undefined;
|
|
7790
|
+
}
|
|
7791
|
+
const tokens = line.match(CandidateLine.regex);
|
|
7792
|
+
const foundation = tokens[1];
|
|
7793
|
+
const componentId = parseInt(tokens[2], 10);
|
|
7794
|
+
const transport = tokens[3];
|
|
7795
|
+
const priority = parseInt(tokens[4], 10);
|
|
7796
|
+
const connectionAddress = tokens[5];
|
|
7797
|
+
const port = parseInt(tokens[6], 10);
|
|
7798
|
+
const candidateType = tokens[7];
|
|
7799
|
+
const relAddr = tokens[8];
|
|
7800
|
+
const relPort = tokens[9] ? parseInt(tokens[9], 10) : undefined;
|
|
7801
|
+
const candidateExtensions = tokens[10];
|
|
7802
|
+
return new CandidateLine(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions);
|
|
7803
|
+
}
|
|
7804
|
+
toSdpLine() {
|
|
7805
|
+
let str = '';
|
|
7806
|
+
str += `a=candidate:${this.foundation} ${this.componentId} ${this.transport} ${this.priority} ${this.connectionAddress} ${this.port} typ ${this.candidateType}`;
|
|
7807
|
+
if (this.relAddr) {
|
|
7808
|
+
str += ` raddr ${this.relAddr}`;
|
|
7809
|
+
}
|
|
7810
|
+
if (this.relPort) {
|
|
7811
|
+
str += ` rport ${this.relPort}`;
|
|
7812
|
+
}
|
|
7813
|
+
if (this.candidateExtensions) {
|
|
7814
|
+
str += ` ${this.candidateExtensions}`;
|
|
7815
|
+
}
|
|
7816
|
+
return str;
|
|
7817
|
+
}
|
|
7818
|
+
}
|
|
7819
|
+
_a$4 = CandidateLine;
|
|
7820
|
+
CandidateLine.ICE_CHARS = `[a-zA-Z0-9+/]+`;
|
|
7821
|
+
CandidateLine.regex = new RegExp(`^candidate:(${_a$4.ICE_CHARS}) (${NUM}) (${ANY_NON_WS}) (${NUM}) (${ANY_NON_WS}) (${NUM}) typ (${ANY_NON_WS})(?: raddr (${ANY_NON_WS}))?(?: rport (${NUM}))?(?: (${REST}))?`);
|
|
7822
|
+
|
|
7823
|
+
class ConnectionLine extends Line {
|
|
7824
|
+
constructor(netType, addrType, ipAddr) {
|
|
7825
|
+
super();
|
|
7826
|
+
this.netType = netType;
|
|
7827
|
+
this.addrType = addrType;
|
|
7828
|
+
this.ipAddr = ipAddr;
|
|
7829
|
+
}
|
|
7830
|
+
static fromSdpLine(line) {
|
|
7831
|
+
if (!ConnectionLine.regex.test(line)) {
|
|
7832
|
+
return undefined;
|
|
7833
|
+
}
|
|
7834
|
+
const tokens = line.match(ConnectionLine.regex);
|
|
7835
|
+
const netType = tokens[1];
|
|
7836
|
+
const addrType = tokens[2];
|
|
7837
|
+
const ipAddr = tokens[3];
|
|
7838
|
+
return new ConnectionLine(netType, addrType, ipAddr);
|
|
7839
|
+
}
|
|
7840
|
+
toSdpLine() {
|
|
7841
|
+
return `c=${this.netType} ${this.addrType} ${this.ipAddr}`;
|
|
7842
|
+
}
|
|
7843
|
+
}
|
|
7844
|
+
ConnectionLine.regex = new RegExp(`^(${ANY_NON_WS}) (${ANY_NON_WS}) (${ANY_NON_WS})`);
|
|
7845
|
+
|
|
7846
|
+
class ContentLine extends Line {
|
|
7847
|
+
constructor(values) {
|
|
7848
|
+
super();
|
|
7849
|
+
this.values = values;
|
|
7850
|
+
}
|
|
7851
|
+
static fromSdpLine(line) {
|
|
7852
|
+
if (!ContentLine.regex.test(line)) {
|
|
7853
|
+
return undefined;
|
|
7854
|
+
}
|
|
7855
|
+
const tokens = line.match(ContentLine.regex);
|
|
7856
|
+
const values = tokens[1].split(',');
|
|
7857
|
+
return new ContentLine(values);
|
|
7858
|
+
}
|
|
7859
|
+
toSdpLine() {
|
|
7860
|
+
return `a=content:${this.values.join(',')}`;
|
|
7861
|
+
}
|
|
7862
|
+
}
|
|
7863
|
+
ContentLine.regex = new RegExp(`^content:(${REST})$`);
|
|
7864
|
+
|
|
7865
|
+
class DirectionLine extends Line {
|
|
7866
|
+
constructor(direction) {
|
|
7867
|
+
super();
|
|
7868
|
+
this.direction = direction;
|
|
7869
|
+
}
|
|
7870
|
+
static fromSdpLine(line) {
|
|
7871
|
+
if (!DirectionLine.regex.test(line)) {
|
|
7872
|
+
return undefined;
|
|
7873
|
+
}
|
|
7874
|
+
const tokens = line.match(DirectionLine.regex);
|
|
7875
|
+
const direction = tokens[1];
|
|
7876
|
+
return new DirectionLine(direction);
|
|
7877
|
+
}
|
|
7878
|
+
toSdpLine() {
|
|
7879
|
+
return `a=${this.direction}`;
|
|
7880
|
+
}
|
|
7881
|
+
}
|
|
7882
|
+
DirectionLine.regex = /^(sendrecv|sendonly|recvonly|inactive)$/;
|
|
7883
|
+
|
|
7884
|
+
var _a$3;
|
|
7885
|
+
class ExtMapLine extends Line {
|
|
7886
|
+
constructor(id, uri, direction, extensionAttributes) {
|
|
7887
|
+
super();
|
|
7888
|
+
this.id = id;
|
|
7889
|
+
this.uri = uri;
|
|
7890
|
+
this.direction = direction;
|
|
7891
|
+
this.extensionAttributes = extensionAttributes;
|
|
7892
|
+
}
|
|
7893
|
+
static fromSdpLine(line) {
|
|
7894
|
+
if (!ExtMapLine.regex.test(line)) {
|
|
7895
|
+
return undefined;
|
|
7896
|
+
}
|
|
7897
|
+
const tokens = line.match(ExtMapLine.regex);
|
|
7898
|
+
const id = parseInt(tokens[1], 10);
|
|
7899
|
+
const direction = tokens[2];
|
|
7900
|
+
const uri = tokens[3];
|
|
7901
|
+
const extensionAttributes = tokens[4];
|
|
7902
|
+
return new ExtMapLine(id, uri, direction, extensionAttributes);
|
|
7903
|
+
}
|
|
7904
|
+
toSdpLine() {
|
|
7905
|
+
let str = '';
|
|
7906
|
+
str += `a=extmap:${this.id}`;
|
|
7907
|
+
if (this.direction) {
|
|
7908
|
+
str += `/${this.direction}`;
|
|
7909
|
+
}
|
|
7910
|
+
str += ` ${this.uri}`;
|
|
7911
|
+
if (this.extensionAttributes) {
|
|
7912
|
+
str += ` ${this.extensionAttributes}`;
|
|
7913
|
+
}
|
|
7914
|
+
return str;
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
_a$3 = ExtMapLine;
|
|
7918
|
+
ExtMapLine.EXTMAP_DIRECTION = `sendonly|recvonly|sendrecv|inactive`;
|
|
7919
|
+
ExtMapLine.regex = new RegExp(`^extmap:(${NUM})(?:/(${_a$3.EXTMAP_DIRECTION}))? (${ANY_NON_WS})(?: (${REST}))?`);
|
|
7920
|
+
|
|
7921
|
+
class FingerprintLine extends Line {
|
|
7922
|
+
constructor(fingerprint) {
|
|
7923
|
+
super();
|
|
7924
|
+
this.fingerprint = fingerprint;
|
|
7925
|
+
}
|
|
7926
|
+
static fromSdpLine(line) {
|
|
7927
|
+
if (!FingerprintLine.regex.test(line)) {
|
|
7928
|
+
return undefined;
|
|
7929
|
+
}
|
|
7930
|
+
const tokens = line.match(FingerprintLine.regex);
|
|
7931
|
+
const fingerprint = tokens[1];
|
|
7932
|
+
return new FingerprintLine(fingerprint);
|
|
7933
|
+
}
|
|
7934
|
+
toSdpLine() {
|
|
7935
|
+
return `a=fingerprint:${this.fingerprint}`;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
FingerprintLine.regex = new RegExp(`^fingerprint:(${REST})`);
|
|
7939
|
+
|
|
7940
|
+
function parseFmtpParams(fmtpParams) {
|
|
7941
|
+
fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
|
|
7942
|
+
const fmtpObj = new Map();
|
|
7943
|
+
if (/^\d+([,/-]\d+)+$/.test(fmtpParams)) {
|
|
7944
|
+
fmtpObj.set(fmtpParams, undefined);
|
|
7945
|
+
return fmtpObj;
|
|
7946
|
+
}
|
|
7947
|
+
fmtpParams.split(';').forEach((param) => {
|
|
7948
|
+
const paramArr = param && param.split('=');
|
|
7949
|
+
if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
|
|
7950
|
+
throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
|
|
7951
|
+
}
|
|
7952
|
+
fmtpObj.set(paramArr[0], paramArr[1]);
|
|
7953
|
+
});
|
|
7954
|
+
return fmtpObj;
|
|
7955
|
+
}
|
|
7956
|
+
class FmtpLine extends Line {
|
|
7957
|
+
constructor(payloadType, params) {
|
|
7958
|
+
super();
|
|
7959
|
+
this.payloadType = payloadType;
|
|
7960
|
+
this.params = params;
|
|
7961
|
+
}
|
|
7962
|
+
static fromSdpLine(line) {
|
|
7963
|
+
if (!FmtpLine.regex.test(line)) {
|
|
7964
|
+
return undefined;
|
|
7965
|
+
}
|
|
7966
|
+
const tokens = line.match(FmtpLine.regex);
|
|
7967
|
+
const payloadType = parseInt(tokens[1], 10);
|
|
7968
|
+
const params = tokens[2];
|
|
7969
|
+
return new FmtpLine(payloadType, parseFmtpParams(params));
|
|
7970
|
+
}
|
|
7971
|
+
toSdpLine() {
|
|
7972
|
+
const fmtParams = Array.from(this.params.keys())
|
|
7973
|
+
.map((key) => {
|
|
7974
|
+
if (this.params.get(key) !== undefined) {
|
|
7975
|
+
return `${key}=${this.params.get(key)}`;
|
|
7976
|
+
}
|
|
7977
|
+
return `${key}`;
|
|
7978
|
+
})
|
|
7979
|
+
.join(';');
|
|
7980
|
+
return `a=fmtp:${this.payloadType} ${fmtParams}`;
|
|
7981
|
+
}
|
|
7982
|
+
}
|
|
7983
|
+
FmtpLine.regex = new RegExp(`^fmtp:(${NUM}) (${REST})`);
|
|
7984
|
+
|
|
7985
|
+
class IceOptionsLine extends Line {
|
|
7986
|
+
constructor(options) {
|
|
7987
|
+
super();
|
|
7988
|
+
this.options = options;
|
|
7989
|
+
}
|
|
7990
|
+
static fromSdpLine(line) {
|
|
7991
|
+
if (!IceOptionsLine.regex.test(line)) {
|
|
7992
|
+
return undefined;
|
|
7993
|
+
}
|
|
7994
|
+
const tokens = line.match(IceOptionsLine.regex);
|
|
7995
|
+
const options = tokens[1].split(' ');
|
|
7996
|
+
return new IceOptionsLine(options);
|
|
7997
|
+
}
|
|
7998
|
+
toSdpLine() {
|
|
7999
|
+
return `a=ice-options:${this.options.join(' ')}`;
|
|
8000
|
+
}
|
|
8001
|
+
}
|
|
8002
|
+
IceOptionsLine.regex = new RegExp(`^ice-options:(${REST})$`);
|
|
8003
|
+
|
|
8004
|
+
class IcePwdLine extends Line {
|
|
8005
|
+
constructor(pwd) {
|
|
8006
|
+
super();
|
|
8007
|
+
this.pwd = pwd;
|
|
8008
|
+
}
|
|
8009
|
+
static fromSdpLine(line) {
|
|
8010
|
+
if (!IcePwdLine.regex.test(line)) {
|
|
8011
|
+
return undefined;
|
|
8012
|
+
}
|
|
8013
|
+
const tokens = line.match(IcePwdLine.regex);
|
|
8014
|
+
const pwd = tokens[1];
|
|
8015
|
+
return new IcePwdLine(pwd);
|
|
8016
|
+
}
|
|
8017
|
+
toSdpLine() {
|
|
8018
|
+
return `a=ice-pwd:${this.pwd}`;
|
|
8019
|
+
}
|
|
8020
|
+
}
|
|
8021
|
+
IcePwdLine.regex = new RegExp(`^ice-pwd:(${ANY_NON_WS})$`);
|
|
8022
|
+
|
|
8023
|
+
class IceUfragLine extends Line {
|
|
8024
|
+
constructor(ufrag) {
|
|
8025
|
+
super();
|
|
8026
|
+
this.ufrag = ufrag;
|
|
8027
|
+
}
|
|
8028
|
+
static fromSdpLine(line) {
|
|
8029
|
+
if (!IceUfragLine.regex.test(line)) {
|
|
8030
|
+
return undefined;
|
|
8031
|
+
}
|
|
8032
|
+
const tokens = line.match(IceUfragLine.regex);
|
|
8033
|
+
const ufrag = tokens[1];
|
|
8034
|
+
return new IceUfragLine(ufrag);
|
|
8035
|
+
}
|
|
8036
|
+
toSdpLine() {
|
|
8037
|
+
return `a=ice-ufrag:${this.ufrag}`;
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
IceUfragLine.regex = new RegExp(`^ice-ufrag:(${ANY_NON_WS})$`);
|
|
8041
|
+
|
|
8042
|
+
class MaxMessageSizeLine extends Line {
|
|
8043
|
+
constructor(maxMessageSize) {
|
|
8044
|
+
super();
|
|
8045
|
+
this.maxMessageSize = maxMessageSize;
|
|
8046
|
+
}
|
|
8047
|
+
static fromSdpLine(line) {
|
|
8048
|
+
if (!MaxMessageSizeLine.regex.test(line)) {
|
|
8049
|
+
return undefined;
|
|
8050
|
+
}
|
|
8051
|
+
const tokens = line.match(MaxMessageSizeLine.regex);
|
|
8052
|
+
const maxMessageSize = parseInt(tokens[1], 10);
|
|
8053
|
+
return new MaxMessageSizeLine(maxMessageSize);
|
|
8054
|
+
}
|
|
8055
|
+
toSdpLine() {
|
|
8056
|
+
return `a=max-message-size:${this.maxMessageSize}`;
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
MaxMessageSizeLine.regex = new RegExp(`^max-message-size:(${NUM})`);
|
|
8060
|
+
|
|
8061
|
+
var _a$2;
|
|
8062
|
+
class MediaLine extends Line {
|
|
8063
|
+
constructor(type, port, protocol, formats) {
|
|
8064
|
+
super();
|
|
8065
|
+
this.type = type;
|
|
8066
|
+
this.port = port;
|
|
8067
|
+
this.protocol = protocol;
|
|
8068
|
+
this.formats = formats;
|
|
8069
|
+
}
|
|
8070
|
+
static fromSdpLine(line) {
|
|
8071
|
+
if (!MediaLine.regex.test(line)) {
|
|
8072
|
+
return undefined;
|
|
8073
|
+
}
|
|
8074
|
+
const tokens = line.match(MediaLine.regex);
|
|
8075
|
+
const type = tokens[1];
|
|
8076
|
+
const port = parseInt(tokens[2], 10);
|
|
8077
|
+
const protocol = tokens[3];
|
|
8078
|
+
const formats = tokens[4].split(' ');
|
|
8079
|
+
return new MediaLine(type, port, protocol, formats);
|
|
8080
|
+
}
|
|
8081
|
+
toSdpLine() {
|
|
8082
|
+
return `m=${this.type} ${this.port} ${this.protocol} ${this.formats.join(' ')}`;
|
|
8083
|
+
}
|
|
8084
|
+
}
|
|
8085
|
+
_a$2 = MediaLine;
|
|
8086
|
+
MediaLine.MEDIA_TYPE = 'audio|video|application';
|
|
8087
|
+
MediaLine.regex = new RegExp(`^(${_a$2.MEDIA_TYPE}) (${NUM}) (${ANY_NON_WS}) (${REST})`);
|
|
8088
|
+
|
|
8089
|
+
class MidLine extends Line {
|
|
8090
|
+
constructor(mid) {
|
|
8091
|
+
super();
|
|
8092
|
+
this.mid = mid;
|
|
8093
|
+
}
|
|
8094
|
+
static fromSdpLine(line) {
|
|
8095
|
+
if (!MidLine.regex.test(line)) {
|
|
8096
|
+
return undefined;
|
|
8097
|
+
}
|
|
8098
|
+
const tokens = line.match(MidLine.regex);
|
|
8099
|
+
const mid = tokens[1];
|
|
8100
|
+
return new MidLine(mid);
|
|
8101
|
+
}
|
|
8102
|
+
toSdpLine() {
|
|
8103
|
+
return `a=mid:${this.mid}`;
|
|
8104
|
+
}
|
|
8105
|
+
}
|
|
8106
|
+
MidLine.regex = new RegExp(`^mid:(${ANY_NON_WS})$`);
|
|
8107
|
+
|
|
8108
|
+
class OriginLine extends Line {
|
|
8109
|
+
constructor(username, sessionId, sessionVersion, netType, addrType, ipAddr) {
|
|
8110
|
+
super();
|
|
8111
|
+
this.username = username;
|
|
8112
|
+
this.sessionId = sessionId;
|
|
8113
|
+
this.sessionVersion = sessionVersion;
|
|
8114
|
+
this.netType = netType;
|
|
8115
|
+
this.addrType = addrType;
|
|
8116
|
+
this.ipAddr = ipAddr;
|
|
8117
|
+
}
|
|
8118
|
+
static fromSdpLine(line) {
|
|
8119
|
+
if (!OriginLine.regex.test(line)) {
|
|
8120
|
+
return undefined;
|
|
8121
|
+
}
|
|
8122
|
+
const tokens = line.match(OriginLine.regex);
|
|
8123
|
+
const username = tokens[1];
|
|
8124
|
+
const sessionId = tokens[2];
|
|
8125
|
+
const sessionVersion = parseInt(tokens[3], 10);
|
|
8126
|
+
const netType = tokens[4];
|
|
8127
|
+
const addrType = tokens[5];
|
|
8128
|
+
const ipAddr = tokens[6];
|
|
8129
|
+
return new OriginLine(username, sessionId, sessionVersion, netType, addrType, ipAddr);
|
|
8130
|
+
}
|
|
8131
|
+
toSdpLine() {
|
|
8132
|
+
return `o=${this.username} ${this.sessionId} ${this.sessionVersion} ${this.netType} ${this.addrType} ${this.ipAddr}`;
|
|
8133
|
+
}
|
|
8134
|
+
}
|
|
8135
|
+
OriginLine.regex = new RegExp(`^(${ANY_NON_WS}) (${ANY_NON_WS}) (${NUM}) (${ANY_NON_WS}) (${ANY_NON_WS}) (${ANY_NON_WS})`);
|
|
8136
|
+
|
|
8137
|
+
var _a$1;
|
|
8138
|
+
class RidLine extends Line {
|
|
8139
|
+
constructor(id, direction, params) {
|
|
8140
|
+
super();
|
|
8141
|
+
this.id = id;
|
|
8142
|
+
this.direction = direction;
|
|
8143
|
+
this.params = params;
|
|
8144
|
+
}
|
|
8145
|
+
static fromSdpLine(line) {
|
|
8146
|
+
if (!RidLine.regex.test(line)) {
|
|
8147
|
+
return undefined;
|
|
8148
|
+
}
|
|
8149
|
+
const tokens = line.match(RidLine.regex);
|
|
8150
|
+
const id = tokens[1];
|
|
8151
|
+
const direction = tokens[2];
|
|
8152
|
+
const params = tokens[3];
|
|
8153
|
+
return new RidLine(id, direction, params);
|
|
8154
|
+
}
|
|
8155
|
+
toSdpLine() {
|
|
8156
|
+
let str = '';
|
|
8157
|
+
str += `a=rid:${this.id} ${this.direction}`;
|
|
8158
|
+
if (this.params) {
|
|
8159
|
+
str += ` ${this.params}`;
|
|
8160
|
+
}
|
|
8161
|
+
return str;
|
|
8162
|
+
}
|
|
8163
|
+
}
|
|
8164
|
+
_a$1 = RidLine;
|
|
8165
|
+
RidLine.RID_ID = `[\\w-]+`;
|
|
8166
|
+
RidLine.RID_DIRECTION = `\\bsend\\b|\\brecv\\b`;
|
|
8167
|
+
RidLine.regex = new RegExp(`^rid:(${_a$1.RID_ID}) (${_a$1.RID_DIRECTION})(?:${SP}(${REST}))?`);
|
|
8168
|
+
|
|
8169
|
+
class RtcpMuxLine extends Line {
|
|
8170
|
+
static fromSdpLine(line) {
|
|
8171
|
+
if (!RtcpMuxLine.regex.test(line)) {
|
|
8172
|
+
return undefined;
|
|
8173
|
+
}
|
|
8174
|
+
return new RtcpMuxLine();
|
|
8175
|
+
}
|
|
8176
|
+
toSdpLine() {
|
|
8177
|
+
return `a=rtcp-mux`;
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
RtcpMuxLine.regex = /^rtcp-mux$/;
|
|
8181
|
+
|
|
8182
|
+
class RtcpFbLine extends Line {
|
|
8183
|
+
constructor(payloadType, feedback) {
|
|
8184
|
+
super();
|
|
8185
|
+
this.payloadType = payloadType;
|
|
8186
|
+
this.feedback = feedback;
|
|
8187
|
+
}
|
|
8188
|
+
static fromSdpLine(line) {
|
|
8189
|
+
if (!RtcpFbLine.regex.test(line)) {
|
|
8190
|
+
return undefined;
|
|
8191
|
+
}
|
|
8192
|
+
const tokens = line.match(RtcpFbLine.regex);
|
|
8193
|
+
const payloadType = parseInt(tokens[1], 10);
|
|
8194
|
+
const feedback = tokens[2];
|
|
8195
|
+
return new RtcpFbLine(payloadType, feedback);
|
|
8196
|
+
}
|
|
8197
|
+
toSdpLine() {
|
|
8198
|
+
return `a=rtcp-fb:${this.payloadType} ${this.feedback}`;
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
RtcpFbLine.regex = new RegExp(`^rtcp-fb:(${NUM}) (${REST})`);
|
|
8202
|
+
|
|
8203
|
+
var _a;
|
|
8204
|
+
class RtpMapLine extends Line {
|
|
8205
|
+
constructor(payloadType, encodingName, clockRate, encodingParams) {
|
|
8206
|
+
super();
|
|
8207
|
+
this.payloadType = payloadType;
|
|
8208
|
+
this.encodingName = encodingName;
|
|
8209
|
+
this.clockRate = clockRate;
|
|
8210
|
+
this.encodingParams = encodingParams;
|
|
8211
|
+
}
|
|
8212
|
+
static fromSdpLine(line) {
|
|
8213
|
+
if (!RtpMapLine.regex.test(line)) {
|
|
8214
|
+
return undefined;
|
|
8215
|
+
}
|
|
8216
|
+
const tokens = line.match(RtpMapLine.regex);
|
|
8217
|
+
const payloadType = parseInt(tokens[1], 10);
|
|
8218
|
+
const encodingName = tokens[2];
|
|
8219
|
+
const clockRate = parseInt(tokens[3], 10);
|
|
8220
|
+
const encodingParams = tokens[4];
|
|
8221
|
+
return new RtpMapLine(payloadType, encodingName, clockRate, encodingParams);
|
|
8222
|
+
}
|
|
8223
|
+
toSdpLine() {
|
|
8224
|
+
let str = '';
|
|
8225
|
+
str += `a=rtpmap:${this.payloadType} ${this.encodingName}/${this.clockRate}`;
|
|
8226
|
+
if (this.encodingParams) {
|
|
8227
|
+
str += `/${this.encodingParams}`;
|
|
8228
|
+
}
|
|
8229
|
+
return str;
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
_a = RtpMapLine;
|
|
8233
|
+
RtpMapLine.NON_SLASH_TOKEN = '[^\\s/]+';
|
|
8234
|
+
RtpMapLine.regex = new RegExp(`^rtpmap:(${NUM}) (${_a.NON_SLASH_TOKEN})/(${_a.NON_SLASH_TOKEN})(?:/(${_a.NON_SLASH_TOKEN}))?`);
|
|
8235
|
+
|
|
8236
|
+
class SctpPortLine extends Line {
|
|
8237
|
+
constructor(port) {
|
|
8238
|
+
super();
|
|
8239
|
+
this.port = port;
|
|
8240
|
+
}
|
|
8241
|
+
static fromSdpLine(line) {
|
|
8242
|
+
if (!SctpPortLine.regex.test(line)) {
|
|
8243
|
+
return undefined;
|
|
8244
|
+
}
|
|
8245
|
+
const tokens = line.match(SctpPortLine.regex);
|
|
8246
|
+
const port = parseInt(tokens[1], 10);
|
|
8247
|
+
return new SctpPortLine(port);
|
|
8248
|
+
}
|
|
8249
|
+
toSdpLine() {
|
|
8250
|
+
return `a=sctp-port:${this.port}`;
|
|
8251
|
+
}
|
|
8252
|
+
}
|
|
8253
|
+
SctpPortLine.regex = new RegExp(`^sctp-port:(${NUM})`);
|
|
8254
|
+
|
|
8255
|
+
class SessionInformationLine extends Line {
|
|
8256
|
+
constructor(info) {
|
|
8257
|
+
super();
|
|
8258
|
+
this.info = info;
|
|
8259
|
+
}
|
|
8260
|
+
static fromSdpLine(line) {
|
|
8261
|
+
if (!SessionInformationLine.regex.test(line)) {
|
|
8262
|
+
return undefined;
|
|
8263
|
+
}
|
|
8264
|
+
const tokens = line.match(SessionInformationLine.regex);
|
|
8265
|
+
const info = tokens[1];
|
|
8266
|
+
return new SessionInformationLine(info);
|
|
8267
|
+
}
|
|
8268
|
+
toSdpLine() {
|
|
8269
|
+
return `i=${this.info}`;
|
|
8270
|
+
}
|
|
8271
|
+
}
|
|
8272
|
+
SessionInformationLine.regex = new RegExp(`(${REST})`);
|
|
8273
|
+
|
|
8274
|
+
class SessionNameLine extends Line {
|
|
8275
|
+
constructor(name) {
|
|
8276
|
+
super();
|
|
8277
|
+
this.name = name;
|
|
8278
|
+
}
|
|
8279
|
+
static fromSdpLine(line) {
|
|
8280
|
+
if (!SessionNameLine.regex.test(line)) {
|
|
8281
|
+
return undefined;
|
|
8282
|
+
}
|
|
8283
|
+
const tokens = line.match(SessionNameLine.regex);
|
|
8284
|
+
const name = tokens[1];
|
|
8285
|
+
return new SessionNameLine(name);
|
|
8286
|
+
}
|
|
8287
|
+
toSdpLine() {
|
|
8288
|
+
return `s=${this.name}`;
|
|
8289
|
+
}
|
|
8290
|
+
}
|
|
8291
|
+
SessionNameLine.regex = new RegExp(`^(${REST})`);
|
|
8292
|
+
|
|
8293
|
+
class SetupLine extends Line {
|
|
8294
|
+
constructor(setup) {
|
|
8295
|
+
super();
|
|
8296
|
+
this.setup = setup;
|
|
8297
|
+
}
|
|
8298
|
+
static fromSdpLine(line) {
|
|
8299
|
+
if (!SetupLine.regex.test(line)) {
|
|
8300
|
+
return undefined;
|
|
8301
|
+
}
|
|
8302
|
+
const tokens = line.match(SetupLine.regex);
|
|
8303
|
+
const setup = tokens[1];
|
|
8304
|
+
return new SetupLine(setup);
|
|
8305
|
+
}
|
|
8306
|
+
toSdpLine() {
|
|
8307
|
+
return `a=setup:${this.setup}`;
|
|
8308
|
+
}
|
|
8309
|
+
}
|
|
8310
|
+
SetupLine.regex = /^setup:(actpass|active|passive)$/;
|
|
8311
|
+
|
|
8312
|
+
class SimulcastLayer {
|
|
8313
|
+
constructor(id, paused) {
|
|
8314
|
+
this.id = id;
|
|
8315
|
+
this.paused = paused;
|
|
8316
|
+
}
|
|
8317
|
+
toString() {
|
|
8318
|
+
return this.paused ? `~${this.id}` : this.id;
|
|
8319
|
+
}
|
|
8320
|
+
}
|
|
8321
|
+
class SimulcastLayerList {
|
|
8322
|
+
constructor() {
|
|
8323
|
+
this.layers = [];
|
|
8324
|
+
}
|
|
8325
|
+
addLayer(layer) {
|
|
8326
|
+
this.layers.push([layer]);
|
|
8327
|
+
}
|
|
8328
|
+
addLayerWithAlternatives(alternatives) {
|
|
8329
|
+
this.layers.push(alternatives);
|
|
8330
|
+
}
|
|
8331
|
+
get length() {
|
|
8332
|
+
return this.layers.length;
|
|
8333
|
+
}
|
|
8334
|
+
get(index) {
|
|
8335
|
+
return this.layers[index];
|
|
8336
|
+
}
|
|
8337
|
+
static fromString(str) {
|
|
8338
|
+
const layerList = new SimulcastLayerList();
|
|
8339
|
+
const tokens = str.split(';');
|
|
8340
|
+
if (tokens.length === 1 && !tokens[0].trim()) {
|
|
8341
|
+
throw new Error('simulcast stream list empty');
|
|
8342
|
+
}
|
|
8343
|
+
tokens.forEach((token) => {
|
|
8344
|
+
if (!token) {
|
|
8345
|
+
throw new Error('simulcast layer list empty');
|
|
8346
|
+
}
|
|
8347
|
+
const ridTokens = token.split(',');
|
|
8348
|
+
const layers = [];
|
|
8349
|
+
ridTokens.forEach((ridToken) => {
|
|
8350
|
+
if (!ridToken || ridToken === '~') {
|
|
8351
|
+
throw new Error('rid empty');
|
|
8352
|
+
}
|
|
8353
|
+
const paused = ridToken[0] === '~';
|
|
8354
|
+
const rid = paused ? ridToken.substring(1) : ridToken;
|
|
8355
|
+
layers.push(new SimulcastLayer(rid, paused));
|
|
8356
|
+
});
|
|
8357
|
+
layerList.addLayerWithAlternatives(layers);
|
|
8358
|
+
});
|
|
8359
|
+
return layerList;
|
|
8360
|
+
}
|
|
8361
|
+
toString() {
|
|
8362
|
+
return this.layers
|
|
8363
|
+
.map((altArray) => altArray.map((v) => v.toString()).join(','))
|
|
8364
|
+
.join(';');
|
|
8365
|
+
}
|
|
8366
|
+
}
|
|
8367
|
+
class SimulcastLine extends Line {
|
|
8368
|
+
constructor(sendLayers, recvLayers) {
|
|
8369
|
+
super();
|
|
8370
|
+
this.sendLayers = sendLayers;
|
|
8371
|
+
this.recvLayers = recvLayers;
|
|
8372
|
+
}
|
|
8373
|
+
static fromSdpLine(line) {
|
|
8374
|
+
if (!SimulcastLine.regex.test(line)) {
|
|
8375
|
+
return undefined;
|
|
8376
|
+
}
|
|
8377
|
+
const tokens = line.match(SimulcastLine.regex);
|
|
8378
|
+
const bidirectional = tokens[3] && tokens[4];
|
|
8379
|
+
const firstDirection = tokens[1];
|
|
8380
|
+
const layerList1 = SimulcastLayerList.fromString(tokens[2]);
|
|
8381
|
+
let layerList2 = new SimulcastLayerList();
|
|
8382
|
+
if (bidirectional) {
|
|
8383
|
+
const secondDirection = tokens[3];
|
|
8384
|
+
if (firstDirection === secondDirection) {
|
|
8385
|
+
return undefined;
|
|
8386
|
+
}
|
|
8387
|
+
layerList2 = SimulcastLayerList.fromString(tokens[4]);
|
|
8388
|
+
}
|
|
8389
|
+
let sendLayerList;
|
|
8390
|
+
let recvLayerList;
|
|
8391
|
+
if (firstDirection === 'send') {
|
|
8392
|
+
sendLayerList = layerList1;
|
|
8393
|
+
recvLayerList = layerList2;
|
|
8394
|
+
}
|
|
8395
|
+
else {
|
|
8396
|
+
sendLayerList = layerList2;
|
|
8397
|
+
recvLayerList = layerList1;
|
|
8398
|
+
}
|
|
8399
|
+
return new SimulcastLine(sendLayerList, recvLayerList);
|
|
8400
|
+
}
|
|
8401
|
+
toSdpLine() {
|
|
8402
|
+
let str = 'a=simulcast:';
|
|
8403
|
+
if (this.sendLayers.length) {
|
|
8404
|
+
str += `send ${this.sendLayers.toString()}`;
|
|
8405
|
+
if (this.recvLayers.length) {
|
|
8406
|
+
str += ` `;
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
if (this.recvLayers.length) {
|
|
8410
|
+
str += `recv ${this.recvLayers.toString()}`;
|
|
8411
|
+
}
|
|
8412
|
+
return str;
|
|
8413
|
+
}
|
|
8414
|
+
}
|
|
8415
|
+
SimulcastLine.regex = new RegExp(`^simulcast:(send|recv) (${ANY_NON_WS})(?: (send|recv) (${ANY_NON_WS}))?`);
|
|
8416
|
+
|
|
8417
|
+
class SsrcLine extends Line {
|
|
8418
|
+
constructor(ssrcId, attribute, attributeValue = undefined, attributeData = undefined) {
|
|
8419
|
+
super();
|
|
8420
|
+
this.ssrcId = ssrcId;
|
|
8421
|
+
this.attribute = attribute;
|
|
8422
|
+
this.attributeValue = attributeValue;
|
|
8423
|
+
this.attributeData = attributeData;
|
|
8424
|
+
}
|
|
8425
|
+
static fromSdpLine(line) {
|
|
8426
|
+
if (!SsrcLine.regex.test(line)) {
|
|
8427
|
+
return undefined;
|
|
8428
|
+
}
|
|
8429
|
+
const tokens = line.match(SsrcLine.regex);
|
|
8430
|
+
const ssrcId = parseInt(tokens[1], 10);
|
|
8431
|
+
const attribute = tokens[2];
|
|
8432
|
+
const attributeValue = tokens[3];
|
|
8433
|
+
const attributeData = tokens[4];
|
|
8434
|
+
return new SsrcLine(ssrcId, attribute, attributeValue, attributeData);
|
|
8435
|
+
}
|
|
8436
|
+
toSdpLine() {
|
|
8437
|
+
let str = `a=ssrc:${this.ssrcId} ${this.attribute}`;
|
|
8438
|
+
if (this.attributeValue) {
|
|
8439
|
+
str += `:${this.attributeValue}`;
|
|
8440
|
+
}
|
|
8441
|
+
if (this.attributeData) {
|
|
8442
|
+
str += ` ${this.attributeData}`;
|
|
8443
|
+
}
|
|
8444
|
+
return str;
|
|
8445
|
+
}
|
|
8446
|
+
}
|
|
8447
|
+
SsrcLine.regex = new RegExp(`^ssrc:(${NUM}) (${SDP_TOKEN})(?::(${SDP_TOKEN})?(?: (${ANY_NON_WS}))?)?$`);
|
|
8448
|
+
|
|
8449
|
+
class SsrcGroupLine extends Line {
|
|
8450
|
+
constructor(semantics, ssrcs) {
|
|
8451
|
+
super();
|
|
8452
|
+
this.semantics = semantics;
|
|
8453
|
+
this.ssrcs = ssrcs;
|
|
8454
|
+
}
|
|
8455
|
+
static fromSdpLine(line) {
|
|
8456
|
+
if (!SsrcGroupLine.regex.test(line)) {
|
|
8457
|
+
return undefined;
|
|
8458
|
+
}
|
|
8459
|
+
const tokens = line.match(SsrcGroupLine.regex);
|
|
8460
|
+
const semantics = tokens[1];
|
|
8461
|
+
const ssrcs = tokens[2].split(' ').map((ssrcStr) => parseInt(ssrcStr, 10));
|
|
8462
|
+
return new SsrcGroupLine(semantics, ssrcs);
|
|
8463
|
+
}
|
|
8464
|
+
toSdpLine() {
|
|
8465
|
+
return `a=ssrc-group:${this.semantics} ${this.ssrcs.join(' ')}`;
|
|
8466
|
+
}
|
|
8467
|
+
}
|
|
8468
|
+
SsrcGroupLine.regex = new RegExp(`^ssrc-group:(SIM|FID|FEC) ((?:${NUM}${SP}*)+)`);
|
|
8469
|
+
|
|
8470
|
+
class TimingLine extends Line {
|
|
8471
|
+
constructor(startTime, stopTime) {
|
|
8472
|
+
super();
|
|
8473
|
+
this.startTime = startTime;
|
|
8474
|
+
this.stopTime = stopTime;
|
|
8475
|
+
}
|
|
8476
|
+
static fromSdpLine(line) {
|
|
8477
|
+
if (!TimingLine.regex.test(line)) {
|
|
8478
|
+
return undefined;
|
|
8479
|
+
}
|
|
8480
|
+
const tokens = line.match(TimingLine.regex);
|
|
8481
|
+
const startTime = parseInt(tokens[1], 10);
|
|
8482
|
+
const stopTime = parseInt(tokens[2], 10);
|
|
8483
|
+
return new TimingLine(startTime, stopTime);
|
|
8484
|
+
}
|
|
8485
|
+
toSdpLine() {
|
|
8486
|
+
return `t=${this.startTime} ${this.stopTime}`;
|
|
8487
|
+
}
|
|
8488
|
+
}
|
|
8489
|
+
TimingLine.regex = new RegExp(`^(${NUM}) (${NUM})`);
|
|
8490
|
+
|
|
8491
|
+
class VersionLine extends Line {
|
|
8492
|
+
constructor(version) {
|
|
8493
|
+
super();
|
|
8494
|
+
this.version = version;
|
|
8495
|
+
}
|
|
8496
|
+
static fromSdpLine(line) {
|
|
8497
|
+
if (!VersionLine.regex.test(line)) {
|
|
8498
|
+
return undefined;
|
|
8499
|
+
}
|
|
8500
|
+
const tokens = line.match(VersionLine.regex);
|
|
8501
|
+
const version = parseInt(tokens[1], 10);
|
|
8502
|
+
return new VersionLine(version);
|
|
8503
|
+
}
|
|
8504
|
+
toSdpLine() {
|
|
8505
|
+
return `v=${this.version}`;
|
|
8506
|
+
}
|
|
8507
|
+
}
|
|
8508
|
+
VersionLine.regex = new RegExp(`^(${NUM})$`);
|
|
8509
|
+
|
|
8510
|
+
class UnknownLine extends Line {
|
|
8511
|
+
constructor(value) {
|
|
8512
|
+
super();
|
|
8513
|
+
this.value = value;
|
|
8514
|
+
}
|
|
8515
|
+
static fromSdpLine(line) {
|
|
8516
|
+
const tokens = line.match(UnknownLine.regex);
|
|
8517
|
+
const value = tokens[1];
|
|
8518
|
+
return new UnknownLine(value);
|
|
8519
|
+
}
|
|
8520
|
+
toSdpLine() {
|
|
8521
|
+
return `${this.value}`;
|
|
8522
|
+
}
|
|
8523
|
+
}
|
|
8524
|
+
UnknownLine.regex = new RegExp(`(${REST})`);
|
|
8525
|
+
|
|
8526
|
+
class IceInfo {
|
|
8527
|
+
constructor() {
|
|
8528
|
+
this.candidates = [];
|
|
8529
|
+
}
|
|
8530
|
+
addLine(line) {
|
|
8531
|
+
if (line instanceof IceUfragLine) {
|
|
8532
|
+
this.ufrag = line;
|
|
8533
|
+
return true;
|
|
8534
|
+
}
|
|
8535
|
+
if (line instanceof IcePwdLine) {
|
|
8536
|
+
this.pwd = line;
|
|
8537
|
+
return true;
|
|
8538
|
+
}
|
|
8539
|
+
if (line instanceof IceOptionsLine) {
|
|
8540
|
+
this.options = line;
|
|
8541
|
+
return true;
|
|
8542
|
+
}
|
|
8543
|
+
if (line instanceof CandidateLine) {
|
|
8544
|
+
this.candidates.push(line);
|
|
8545
|
+
return true;
|
|
8546
|
+
}
|
|
8547
|
+
return false;
|
|
8548
|
+
}
|
|
8549
|
+
toLines() {
|
|
8550
|
+
const lines = [];
|
|
8551
|
+
if (this.ufrag) {
|
|
8552
|
+
lines.push(this.ufrag);
|
|
8553
|
+
}
|
|
8554
|
+
if (this.pwd) {
|
|
8555
|
+
lines.push(this.pwd);
|
|
8556
|
+
}
|
|
8557
|
+
if (this.options) {
|
|
8558
|
+
lines.push(this.options);
|
|
8559
|
+
}
|
|
8560
|
+
this.candidates.forEach((candidate) => lines.push(candidate));
|
|
8561
|
+
return lines;
|
|
8562
|
+
}
|
|
8563
|
+
}
|
|
8564
|
+
|
|
8565
|
+
class MediaDescription {
|
|
8566
|
+
constructor(type, port, protocol) {
|
|
8567
|
+
this.iceInfo = new IceInfo();
|
|
8568
|
+
this.otherLines = [];
|
|
8569
|
+
this.type = type;
|
|
8570
|
+
this.port = port;
|
|
8571
|
+
this.protocol = protocol;
|
|
8572
|
+
}
|
|
8573
|
+
findOtherLine(ty) {
|
|
8574
|
+
return this.otherLines.find((line) => line instanceof ty);
|
|
8575
|
+
}
|
|
8576
|
+
addLine(line) {
|
|
8577
|
+
if (line instanceof BundleGroupLine) {
|
|
8578
|
+
throw new Error(`Error: bundle group line not allowed in media description`);
|
|
8579
|
+
}
|
|
8580
|
+
if (line instanceof BandwidthLine) {
|
|
8581
|
+
this.bandwidth = line;
|
|
8582
|
+
return true;
|
|
8583
|
+
}
|
|
8584
|
+
if (line instanceof MidLine) {
|
|
8585
|
+
this.mid = line.mid;
|
|
8586
|
+
return true;
|
|
8587
|
+
}
|
|
8588
|
+
if (line instanceof FingerprintLine) {
|
|
8589
|
+
this.fingerprint = line.fingerprint;
|
|
8590
|
+
return true;
|
|
8591
|
+
}
|
|
8592
|
+
if (line instanceof SetupLine) {
|
|
8593
|
+
this.setup = line.setup;
|
|
8594
|
+
return true;
|
|
8595
|
+
}
|
|
8596
|
+
if (line instanceof ConnectionLine) {
|
|
8597
|
+
this.connection = line;
|
|
8598
|
+
return true;
|
|
8599
|
+
}
|
|
8600
|
+
if (line instanceof ContentLine) {
|
|
8601
|
+
this.content = line;
|
|
8602
|
+
return true;
|
|
8603
|
+
}
|
|
8604
|
+
return this.iceInfo.addLine(line);
|
|
8605
|
+
}
|
|
8606
|
+
}
|
|
8607
|
+
|
|
8608
|
+
class ApplicationMediaDescription extends MediaDescription {
|
|
8609
|
+
constructor(mediaLine) {
|
|
8610
|
+
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
8611
|
+
this.fmts = [];
|
|
8612
|
+
this.fmts = mediaLine.formats;
|
|
8613
|
+
}
|
|
8614
|
+
toLines() {
|
|
8615
|
+
const lines = [];
|
|
8616
|
+
lines.push(new MediaLine(this.type, this.port, this.protocol, this.fmts));
|
|
8617
|
+
if (this.connection) {
|
|
8618
|
+
lines.push(this.connection);
|
|
8619
|
+
}
|
|
8620
|
+
if (this.bandwidth) {
|
|
8621
|
+
lines.push(this.bandwidth);
|
|
8622
|
+
}
|
|
8623
|
+
lines.push(...this.iceInfo.toLines());
|
|
8624
|
+
if (this.fingerprint) {
|
|
8625
|
+
lines.push(new FingerprintLine(this.fingerprint));
|
|
8626
|
+
}
|
|
8627
|
+
if (this.setup) {
|
|
8628
|
+
lines.push(new SetupLine(this.setup));
|
|
8629
|
+
}
|
|
8630
|
+
if (this.mid) {
|
|
8631
|
+
lines.push(new MidLine(this.mid));
|
|
8632
|
+
}
|
|
8633
|
+
if (this.content) {
|
|
8634
|
+
lines.push(this.content);
|
|
8635
|
+
}
|
|
8636
|
+
if (this.sctpPort) {
|
|
8637
|
+
lines.push(new SctpPortLine(this.sctpPort));
|
|
8638
|
+
}
|
|
8639
|
+
if (this.maxMessageSize) {
|
|
8640
|
+
lines.push(new MaxMessageSizeLine(this.maxMessageSize));
|
|
8641
|
+
}
|
|
8642
|
+
lines.push(...this.otherLines);
|
|
8643
|
+
return lines;
|
|
8644
|
+
}
|
|
8645
|
+
addLine(line) {
|
|
8646
|
+
if (super.addLine(line)) {
|
|
8647
|
+
return true;
|
|
8648
|
+
}
|
|
8649
|
+
if (line instanceof MediaLine) {
|
|
8650
|
+
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
8651
|
+
}
|
|
8652
|
+
if (line instanceof SctpPortLine) {
|
|
8653
|
+
this.sctpPort = line.port;
|
|
8654
|
+
return true;
|
|
8655
|
+
}
|
|
8656
|
+
if (line instanceof MaxMessageSizeLine) {
|
|
8657
|
+
this.maxMessageSize = line.maxMessageSize;
|
|
8658
|
+
return true;
|
|
8659
|
+
}
|
|
8660
|
+
this.otherLines.push(line);
|
|
8661
|
+
return true;
|
|
8662
|
+
}
|
|
8663
|
+
}
|
|
8664
|
+
|
|
8665
|
+
class CodecInfo {
|
|
8666
|
+
constructor(pt) {
|
|
8667
|
+
this.fmtParams = new Map();
|
|
8668
|
+
this.feedback = [];
|
|
8669
|
+
this.pt = pt;
|
|
8670
|
+
}
|
|
8671
|
+
addLine(line) {
|
|
8672
|
+
if (line instanceof RtpMapLine) {
|
|
8673
|
+
this.name = line.encodingName;
|
|
8674
|
+
this.clockRate = line.clockRate;
|
|
8675
|
+
this.encodingParams = line.encodingParams;
|
|
8676
|
+
return true;
|
|
8677
|
+
}
|
|
8678
|
+
if (line instanceof FmtpLine) {
|
|
8679
|
+
this.fmtParams = new Map([
|
|
8680
|
+
...Array.from(this.fmtParams.entries()),
|
|
8681
|
+
...Array.from(line.params.entries()),
|
|
8682
|
+
]);
|
|
8683
|
+
if (line.params.has('apt')) {
|
|
8684
|
+
const apt = line.params.get('apt');
|
|
8685
|
+
this.primaryCodecPt = parseInt(apt, 10);
|
|
8686
|
+
}
|
|
8687
|
+
return true;
|
|
8688
|
+
}
|
|
8689
|
+
if (line instanceof RtcpFbLine) {
|
|
8690
|
+
this.feedback.push(line.feedback);
|
|
8691
|
+
return true;
|
|
8692
|
+
}
|
|
8693
|
+
return false;
|
|
8694
|
+
}
|
|
8695
|
+
toLines() {
|
|
8696
|
+
const lines = [];
|
|
8697
|
+
if (this.name && this.clockRate) {
|
|
8698
|
+
lines.push(new RtpMapLine(this.pt, this.name, this.clockRate, this.encodingParams));
|
|
8699
|
+
}
|
|
8700
|
+
this.feedback.forEach((fb) => {
|
|
8701
|
+
lines.push(new RtcpFbLine(this.pt, fb));
|
|
8702
|
+
});
|
|
8703
|
+
if (this.fmtParams.size > 0) {
|
|
8704
|
+
lines.push(new FmtpLine(this.pt, this.fmtParams));
|
|
8705
|
+
}
|
|
8706
|
+
return lines;
|
|
8707
|
+
}
|
|
8708
|
+
}
|
|
8709
|
+
|
|
8710
|
+
class AvMediaDescription extends MediaDescription {
|
|
8711
|
+
constructor(mediaLine) {
|
|
8712
|
+
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
8713
|
+
this.pts = [];
|
|
8714
|
+
this.extMaps = new Map();
|
|
8715
|
+
this.rids = [];
|
|
8716
|
+
this.codecs = new Map();
|
|
8717
|
+
this.rtcpMux = false;
|
|
8718
|
+
this.ssrcs = [];
|
|
8719
|
+
this.ssrcGroups = [];
|
|
8720
|
+
this.pts = mediaLine.formats.map((fmt) => {
|
|
8721
|
+
return parseInt(fmt, 10);
|
|
8722
|
+
});
|
|
8723
|
+
this.pts.forEach((pt) => this.codecs.set(pt, new CodecInfo(pt)));
|
|
8724
|
+
}
|
|
8725
|
+
toLines() {
|
|
8726
|
+
const lines = [];
|
|
8727
|
+
lines.push(new MediaLine(this.type, this.port, this.protocol, this.pts.map((pt) => `${pt}`)));
|
|
8728
|
+
if (this.connection) {
|
|
8729
|
+
lines.push(this.connection);
|
|
8730
|
+
}
|
|
8731
|
+
if (this.bandwidth) {
|
|
8732
|
+
lines.push(this.bandwidth);
|
|
8733
|
+
}
|
|
8734
|
+
lines.push(...this.iceInfo.toLines());
|
|
8735
|
+
if (this.fingerprint) {
|
|
8736
|
+
lines.push(new FingerprintLine(this.fingerprint));
|
|
8737
|
+
}
|
|
8738
|
+
if (this.setup) {
|
|
8739
|
+
lines.push(new SetupLine(this.setup));
|
|
8740
|
+
}
|
|
8741
|
+
if (this.mid) {
|
|
8742
|
+
lines.push(new MidLine(this.mid));
|
|
8743
|
+
}
|
|
8744
|
+
if (this.rtcpMux) {
|
|
8745
|
+
lines.push(new RtcpMuxLine());
|
|
8746
|
+
}
|
|
8747
|
+
if (this.content) {
|
|
8748
|
+
lines.push(this.content);
|
|
8749
|
+
}
|
|
8750
|
+
this.extMaps.forEach((extMap) => lines.push(extMap));
|
|
8751
|
+
this.rids.forEach((rid) => lines.push(rid));
|
|
8752
|
+
if (this.simulcast) {
|
|
8753
|
+
lines.push(this.simulcast);
|
|
8754
|
+
}
|
|
8755
|
+
if (this.direction) {
|
|
8756
|
+
lines.push(new DirectionLine(this.direction));
|
|
8757
|
+
}
|
|
8758
|
+
this.codecs.forEach((codec) => lines.push(...codec.toLines()));
|
|
8759
|
+
lines.push(...this.ssrcs);
|
|
8760
|
+
lines.push(...this.ssrcGroups);
|
|
8761
|
+
lines.push(...this.otherLines);
|
|
8762
|
+
return lines;
|
|
8763
|
+
}
|
|
8764
|
+
addLine(line) {
|
|
8765
|
+
if (super.addLine(line)) {
|
|
8766
|
+
return true;
|
|
8767
|
+
}
|
|
8768
|
+
if (line instanceof MediaLine) {
|
|
8769
|
+
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
8770
|
+
}
|
|
8771
|
+
if (line instanceof DirectionLine) {
|
|
8772
|
+
this.direction = line.direction;
|
|
8773
|
+
return true;
|
|
8774
|
+
}
|
|
8775
|
+
if (line instanceof ExtMapLine) {
|
|
8776
|
+
if (this.extMaps.has(line.id)) {
|
|
8777
|
+
throw new Error(`Tried to extension with duplicate ID: an extension already exists with ID ${line.id}`);
|
|
8778
|
+
}
|
|
8779
|
+
this.extMaps.set(line.id, line);
|
|
8780
|
+
return true;
|
|
8781
|
+
}
|
|
8782
|
+
if (line instanceof RidLine) {
|
|
8783
|
+
this.rids.push(line);
|
|
8784
|
+
return true;
|
|
8785
|
+
}
|
|
8786
|
+
if (line instanceof RtcpMuxLine) {
|
|
8787
|
+
this.rtcpMux = true;
|
|
8788
|
+
return true;
|
|
8789
|
+
}
|
|
8790
|
+
if (line instanceof SimulcastLine) {
|
|
8791
|
+
this.simulcast = line;
|
|
8792
|
+
return true;
|
|
8793
|
+
}
|
|
8794
|
+
if (line instanceof RtpMapLine || line instanceof FmtpLine || line instanceof RtcpFbLine) {
|
|
8795
|
+
const codec = this.codecs.get(line.payloadType);
|
|
8796
|
+
if (!codec) {
|
|
8797
|
+
throw new Error(`Error: got line for unknown codec: ${line.toSdpLine()}`);
|
|
8798
|
+
}
|
|
8799
|
+
codec.addLine(line);
|
|
8800
|
+
return true;
|
|
8801
|
+
}
|
|
8802
|
+
if (line instanceof SsrcLine) {
|
|
8803
|
+
this.ssrcs.push(line);
|
|
8804
|
+
return true;
|
|
8805
|
+
}
|
|
8806
|
+
if (line instanceof SsrcGroupLine) {
|
|
8807
|
+
this.ssrcGroups.push(line);
|
|
8808
|
+
return true;
|
|
8809
|
+
}
|
|
8810
|
+
this.otherLines.push(line);
|
|
8811
|
+
return true;
|
|
8812
|
+
}
|
|
8813
|
+
getCodecByPt(pt) {
|
|
8814
|
+
return this.codecs.get(pt);
|
|
8815
|
+
}
|
|
8816
|
+
removePt(pt) {
|
|
8817
|
+
const associatedPts = [...this.codecs.values()]
|
|
8818
|
+
.filter((ci) => ci.primaryCodecPt === pt)
|
|
8819
|
+
.map((ci) => ci.pt);
|
|
8820
|
+
const allPtsToRemove = [pt, ...associatedPts];
|
|
8821
|
+
allPtsToRemove.forEach((ptToRemove) => {
|
|
8822
|
+
this.codecs.delete(ptToRemove);
|
|
8823
|
+
});
|
|
8824
|
+
this.pts = this.pts.filter((existingPt) => allPtsToRemove.indexOf(existingPt) === -1);
|
|
8825
|
+
}
|
|
8826
|
+
addExtension({ uri, direction, attributes, id, }) {
|
|
8827
|
+
const getFirstFreeId = () => {
|
|
8828
|
+
let freeId = 1;
|
|
8829
|
+
for (;;) {
|
|
8830
|
+
if (!this.extMaps.has(freeId)) {
|
|
8831
|
+
break;
|
|
8832
|
+
}
|
|
8833
|
+
freeId += 1;
|
|
8834
|
+
}
|
|
8835
|
+
return freeId;
|
|
8836
|
+
};
|
|
8837
|
+
const extId = id || getFirstFreeId();
|
|
8838
|
+
if (this.extMaps.has(extId)) {
|
|
8839
|
+
throw new Error(`Extension with ID ${id} already exists`);
|
|
8840
|
+
}
|
|
8841
|
+
if (extId === 0) {
|
|
8842
|
+
throw new Error(`Extension ID 0 is reserved`);
|
|
8843
|
+
}
|
|
8844
|
+
this.extMaps.set(extId, new ExtMapLine(extId, uri, direction, attributes));
|
|
8845
|
+
}
|
|
8846
|
+
}
|
|
8847
|
+
|
|
8848
|
+
class SessionDescription {
|
|
8849
|
+
constructor() {
|
|
8850
|
+
this.groups = [];
|
|
8851
|
+
this.otherLines = [];
|
|
8852
|
+
}
|
|
8853
|
+
addLine(line) {
|
|
8854
|
+
if (line instanceof VersionLine) {
|
|
8855
|
+
this.version = line;
|
|
8856
|
+
return true;
|
|
8857
|
+
}
|
|
8858
|
+
if (line instanceof OriginLine) {
|
|
8859
|
+
this.origin = line;
|
|
8860
|
+
return true;
|
|
8861
|
+
}
|
|
8862
|
+
if (line instanceof SessionNameLine) {
|
|
8863
|
+
this.sessionName = line;
|
|
8864
|
+
return true;
|
|
8865
|
+
}
|
|
8866
|
+
if (line instanceof SessionInformationLine) {
|
|
8867
|
+
this.information = line;
|
|
8868
|
+
return true;
|
|
8869
|
+
}
|
|
8870
|
+
if (line instanceof TimingLine) {
|
|
8871
|
+
this.timing = line;
|
|
8872
|
+
return true;
|
|
8873
|
+
}
|
|
8874
|
+
if (line instanceof ConnectionLine) {
|
|
8875
|
+
this.connection = line;
|
|
8876
|
+
return true;
|
|
8877
|
+
}
|
|
8878
|
+
if (line instanceof BandwidthLine) {
|
|
8879
|
+
this.bandwidth = line;
|
|
8880
|
+
return true;
|
|
8881
|
+
}
|
|
8882
|
+
if (line instanceof BundleGroupLine) {
|
|
8883
|
+
this.groups.push(line);
|
|
8884
|
+
return true;
|
|
8885
|
+
}
|
|
8886
|
+
this.otherLines.push(line);
|
|
8887
|
+
return true;
|
|
8888
|
+
}
|
|
8889
|
+
toLines() {
|
|
8890
|
+
const lines = [];
|
|
8891
|
+
if (this.version) {
|
|
8892
|
+
lines.push(this.version);
|
|
8893
|
+
}
|
|
8894
|
+
if (this.origin) {
|
|
8895
|
+
lines.push(this.origin);
|
|
8896
|
+
}
|
|
8897
|
+
if (this.sessionName) {
|
|
8898
|
+
lines.push(this.sessionName);
|
|
8899
|
+
}
|
|
8900
|
+
if (this.information) {
|
|
8901
|
+
lines.push(this.information);
|
|
8902
|
+
}
|
|
8903
|
+
if (this.connection) {
|
|
8904
|
+
lines.push(this.connection);
|
|
8905
|
+
}
|
|
8906
|
+
if (this.bandwidth) {
|
|
8907
|
+
lines.push(this.bandwidth);
|
|
8908
|
+
}
|
|
8909
|
+
if (this.timing) {
|
|
8910
|
+
lines.push(this.timing);
|
|
8911
|
+
}
|
|
8912
|
+
if (this.groups) {
|
|
8913
|
+
lines.push(...this.groups);
|
|
8914
|
+
}
|
|
8915
|
+
lines.push(...this.otherLines);
|
|
8916
|
+
return lines;
|
|
8917
|
+
}
|
|
8918
|
+
}
|
|
8919
|
+
|
|
8920
|
+
class Sdp {
|
|
8921
|
+
constructor() {
|
|
8922
|
+
this.session = new SessionDescription();
|
|
8923
|
+
this.media = [];
|
|
8924
|
+
}
|
|
8925
|
+
get avMedia() {
|
|
8926
|
+
return this.media.filter((mi) => mi instanceof AvMediaDescription);
|
|
8927
|
+
}
|
|
8928
|
+
toString() {
|
|
8929
|
+
const lines = [];
|
|
8930
|
+
lines.push(...this.session.toLines());
|
|
8931
|
+
this.media.forEach((m) => lines.push(...m.toLines()));
|
|
8932
|
+
return `${lines.map((l) => l.toSdpLine()).join('\r\n')}\r\n`;
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8935
|
+
|
|
8936
|
+
class Grammar {
|
|
8937
|
+
constructor() {
|
|
8938
|
+
this.parsers = new Map();
|
|
8939
|
+
}
|
|
8940
|
+
addParser(lineType, parser) {
|
|
8941
|
+
const parsers = this.parsers.get(lineType) || [];
|
|
8942
|
+
parsers.push(parser);
|
|
8943
|
+
this.parsers.set(lineType, parsers);
|
|
8944
|
+
}
|
|
8945
|
+
getParsers(lineType) {
|
|
8946
|
+
return this.parsers.get(lineType) || [];
|
|
8947
|
+
}
|
|
8948
|
+
}
|
|
8949
|
+
class SdpGrammar extends Grammar {
|
|
8950
|
+
constructor() {
|
|
8951
|
+
super();
|
|
8952
|
+
this.addParser('v', VersionLine.fromSdpLine);
|
|
8953
|
+
this.addParser('o', OriginLine.fromSdpLine);
|
|
8954
|
+
this.addParser('c', ConnectionLine.fromSdpLine);
|
|
8955
|
+
this.addParser('i', SessionInformationLine.fromSdpLine);
|
|
8956
|
+
this.addParser('m', MediaLine.fromSdpLine);
|
|
8957
|
+
this.addParser('s', SessionNameLine.fromSdpLine);
|
|
8958
|
+
this.addParser('t', TimingLine.fromSdpLine);
|
|
8959
|
+
this.addParser('b', BandwidthLine.fromSdpLine);
|
|
8960
|
+
this.addParser('a', RtpMapLine.fromSdpLine);
|
|
8961
|
+
this.addParser('a', RtcpFbLine.fromSdpLine);
|
|
8962
|
+
this.addParser('a', FmtpLine.fromSdpLine);
|
|
8963
|
+
this.addParser('a', DirectionLine.fromSdpLine);
|
|
8964
|
+
this.addParser('a', ExtMapLine.fromSdpLine);
|
|
8965
|
+
this.addParser('a', MidLine.fromSdpLine);
|
|
8966
|
+
this.addParser('a', IceUfragLine.fromSdpLine);
|
|
8967
|
+
this.addParser('a', IcePwdLine.fromSdpLine);
|
|
8968
|
+
this.addParser('a', IceOptionsLine.fromSdpLine);
|
|
8969
|
+
this.addParser('a', FingerprintLine.fromSdpLine);
|
|
8970
|
+
this.addParser('a', SetupLine.fromSdpLine);
|
|
8971
|
+
this.addParser('a', SctpPortLine.fromSdpLine);
|
|
8972
|
+
this.addParser('a', MaxMessageSizeLine.fromSdpLine);
|
|
8973
|
+
this.addParser('a', RtcpMuxLine.fromSdpLine);
|
|
8974
|
+
this.addParser('a', BundleGroupLine.fromSdpLine);
|
|
8975
|
+
this.addParser('a', ContentLine.fromSdpLine);
|
|
8976
|
+
this.addParser('a', RidLine.fromSdpLine);
|
|
8977
|
+
this.addParser('a', CandidateLine.fromSdpLine);
|
|
8978
|
+
this.addParser('a', SimulcastLine.fromSdpLine);
|
|
8979
|
+
this.addParser('a', SsrcLine.fromSdpLine);
|
|
8980
|
+
this.addParser('a', SsrcGroupLine.fromSdpLine);
|
|
8981
|
+
}
|
|
8982
|
+
}
|
|
8983
|
+
const DefaultSdpGrammar = new SdpGrammar();
|
|
8984
|
+
function isValidLine(line) {
|
|
8985
|
+
return line.length > 2;
|
|
8986
|
+
}
|
|
8987
|
+
function parseToModel(lines) {
|
|
8988
|
+
const sdp = new Sdp();
|
|
8989
|
+
let currBlock = sdp.session;
|
|
8990
|
+
lines.forEach((l) => {
|
|
8991
|
+
if (l instanceof MediaLine) {
|
|
8992
|
+
let mediaInfo;
|
|
8993
|
+
if (l.type === 'audio' || l.type === 'video') {
|
|
8994
|
+
mediaInfo = new AvMediaDescription(l);
|
|
8995
|
+
}
|
|
8996
|
+
else if (l.type === 'application') {
|
|
8997
|
+
mediaInfo = new ApplicationMediaDescription(l);
|
|
8998
|
+
}
|
|
8999
|
+
else {
|
|
9000
|
+
throw new Error(`Unhandled media type: ${l.type}`);
|
|
9001
|
+
}
|
|
9002
|
+
sdp.media.push(mediaInfo);
|
|
9003
|
+
currBlock = mediaInfo;
|
|
9004
|
+
}
|
|
9005
|
+
else {
|
|
9006
|
+
currBlock.addLine(l);
|
|
9007
|
+
}
|
|
9008
|
+
});
|
|
9009
|
+
return sdp;
|
|
9010
|
+
}
|
|
9011
|
+
function parseToLines(sdp, grammar) {
|
|
9012
|
+
const lines = [];
|
|
9013
|
+
sdp
|
|
9014
|
+
.split(/(\r\n|\r|\n)/)
|
|
9015
|
+
.filter(isValidLine)
|
|
9016
|
+
.forEach((l) => {
|
|
9017
|
+
const lineType = l[0];
|
|
9018
|
+
const lineValue = l.slice(2);
|
|
9019
|
+
const parsers = grammar.getParsers(lineType);
|
|
9020
|
+
for (const parser of parsers) {
|
|
9021
|
+
const result = parser(lineValue);
|
|
9022
|
+
if (result) {
|
|
9023
|
+
lines.push(result);
|
|
9024
|
+
return;
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
9027
|
+
const result = UnknownLine.fromSdpLine(l);
|
|
9028
|
+
lines.push(result);
|
|
9029
|
+
});
|
|
9030
|
+
return lines;
|
|
9031
|
+
}
|
|
9032
|
+
function parse(sdp, grammar = DefaultSdpGrammar) {
|
|
9033
|
+
const lines = parseToLines(sdp, grammar);
|
|
9034
|
+
const parsed = parseToModel(lines);
|
|
9035
|
+
return parsed;
|
|
9036
|
+
}
|
|
9037
|
+
function removeCodec(sdpOrAv, codecName) {
|
|
9038
|
+
const mediaDescriptions = sdpOrAv instanceof Sdp ? sdpOrAv.avMedia : [sdpOrAv];
|
|
9039
|
+
mediaDescriptions.forEach((media) => {
|
|
9040
|
+
const codecInfos = [...media.codecs.entries()].filter(([, ci]) => { var _a; return ((_a = ci.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === codecName.toLowerCase(); });
|
|
9041
|
+
codecInfos.forEach(([pt]) => media.removePt(pt));
|
|
9042
|
+
});
|
|
9043
|
+
}
|
|
9044
|
+
function retainCodecs(sdpOrAv, allowedCodecNames) {
|
|
9045
|
+
const avMediaDescriptions = sdpOrAv instanceof Sdp ? sdpOrAv.avMedia : [sdpOrAv];
|
|
9046
|
+
const allowedLowerCase = allowedCodecNames.map((s) => s.toLowerCase());
|
|
9047
|
+
avMediaDescriptions
|
|
9048
|
+
.map((av) => {
|
|
9049
|
+
return [...av.codecs.values()].map((c) => c.name);
|
|
9050
|
+
})
|
|
9051
|
+
.flat()
|
|
9052
|
+
.filter((codecName) => !allowedLowerCase.includes(codecName.toLowerCase()))
|
|
9053
|
+
.forEach((unwantedCodec) => removeCodec(sdpOrAv, unwantedCodec));
|
|
9054
|
+
}
|
|
9055
|
+
function retainCandidates(sdpOrMedia, allowedTransportTypes) {
|
|
9056
|
+
const mediaDescriptions = sdpOrMedia instanceof Sdp ? sdpOrMedia.media : [sdpOrMedia];
|
|
9057
|
+
let filtered = false;
|
|
9058
|
+
mediaDescriptions.forEach((media) => {
|
|
9059
|
+
media.iceInfo.candidates = media.iceInfo.candidates.filter((candidate) => {
|
|
9060
|
+
if (allowedTransportTypes.includes(candidate.transport.toLowerCase())) {
|
|
9061
|
+
return true;
|
|
9062
|
+
}
|
|
9063
|
+
filtered = true;
|
|
9064
|
+
return false;
|
|
9065
|
+
});
|
|
9066
|
+
});
|
|
9067
|
+
return filtered;
|
|
9068
|
+
}
|
|
9069
|
+
|
|
9070
|
+
function hasCodec(codecName, mLine) {
|
|
9071
|
+
return [...mLine.codecs.values()].some((ci) => { var _a; return ((_a = ci.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === codecName.toLowerCase(); });
|
|
9072
|
+
}
|
|
9079
9073
|
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
function
|
|
9089
|
-
return logger.getLevel();
|
|
9074
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9075
|
+
|
|
9076
|
+
function getDefaultExportFromCjs (x) {
|
|
9077
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9078
|
+
}
|
|
9079
|
+
|
|
9080
|
+
var es5 = {exports: {}};
|
|
9081
|
+
|
|
9082
|
+
(function (module, exports) {
|
|
9083
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return "NT";case"XP":return "XP";case"NT 5.0":return "2000";case"NT 5.1":return "XP";case"NT 5.2":return "2003";case"NT 6.0":return "Vista";case"NT 6.1":return "7";case"NT 6.2":return "8";case"NT 6.3":return "8.1";case"NT 10.0":return "10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return "Leopard";case 6:return "Snow Leopard";case 7:return "Lion";case 8:return "Mountain Lion";case 9:return "Mavericks";case 10:return "Yosemite";case 11:return "El Capitan";case 12:return "Sierra";case 13:return "High Sierra";case 14:return "Mojave";case 15:return "Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),a=Math.max(i,s),o=0,u=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(o=a-Math.min(i,s)),a-=1;a>=o;){if(u[0][a]>u[1][a])return 1;if(u[0][a]===u[1][a]){if(a===o)return 0;a-=1;}else if(u[0][a]<u[1][a])return -1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var o=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t];}));};for(t=0,r=s.length;t<r;t+=1)o();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default;},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0;t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"};t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"};t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"};t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"};t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}var o=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&a(t.prototype,r),n&&a(t,n),e}();t.default=o,e.exports=t.default;},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=u(r(92)),i=u(r(93)),s=u(r(94)),a=u(r(95)),o=u(r(17));function u(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse();}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=o.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=o.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=o.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=o.default.find(a.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return o.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var a=e[t];"string"==typeof a?(i[t]=a,s+=1):"object"==typeof a&&(r[t]=a,n+=1);})),n>0){var a=Object.keys(r),u=o.default.find(a,(function(e){return t.isOS(e)}));if(u){var d=this.satisfies(r[u]);if(void 0!==d)return d}var c=o.default.find(a,(function(e){return t.isPlatform(e)}));if(c){var f=this.satisfies(r[c]);if(void 0!==f)return f}}if(s>0){var l=Object.keys(i),h=o.default.find(l,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=o.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return ">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(o.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default;},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n};var s=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return {name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default;},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return {name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return {name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return {name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return {name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return {name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return {name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default;},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:[/googlebot/i],describe:function(){return {type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return {type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "blackberry"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return "bada"===e.getBrowserName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "windows phone"===e.getBrowserName()},describe:function(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return "android"===e.getOSName(!0)&&t>=3},describe:function(){return {type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return "android"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return "macos"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return "windows"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "linux"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return "playstation 4"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}},{test:function(e){return "roku"===e.getOSName(!0)},describe:function(){return {type:s.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default;},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18);var a=[{test:function(e){return "microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return {name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return {name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return {name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default;}})}));
|
|
9084
|
+
}(es5));
|
|
9085
|
+
|
|
9086
|
+
var Bowser = /*@__PURE__*/getDefaultExportFromCjs(es5.exports);
|
|
9087
|
+
|
|
9088
|
+
var BrowserName;
|
|
9089
|
+
(function (BrowserName) {
|
|
9090
|
+
BrowserName["CHROME"] = "Chrome";
|
|
9091
|
+
BrowserName["FIREFOX"] = "Firefox";
|
|
9092
|
+
BrowserName["EDGE"] = "Microsoft Edge";
|
|
9093
|
+
BrowserName["SAFARI"] = "Safari";
|
|
9094
|
+
})(BrowserName || (BrowserName = {}));
|
|
9095
|
+
class BrowserInfo {
|
|
9096
|
+
static getBrowserDetails() {
|
|
9097
|
+
return this.browser.getBrowser();
|
|
9098
|
+
}
|
|
9099
|
+
static getOSDetails() {
|
|
9100
|
+
return this.browser.getOS();
|
|
9101
|
+
}
|
|
9102
|
+
static getPlatformDetails() {
|
|
9103
|
+
return this.browser.getPlatform();
|
|
9104
|
+
}
|
|
9105
|
+
static getEngineDetails() {
|
|
9106
|
+
return this.browser.getEngine();
|
|
9107
|
+
}
|
|
9108
|
+
static isChrome() {
|
|
9109
|
+
return this.browser.getBrowserName() === BrowserName.CHROME;
|
|
9110
|
+
}
|
|
9111
|
+
static isFirefox() {
|
|
9112
|
+
return this.browser.getBrowserName() === BrowserName.FIREFOX;
|
|
9113
|
+
}
|
|
9114
|
+
static isEdge() {
|
|
9115
|
+
return this.browser.getBrowserName() === BrowserName.EDGE;
|
|
9116
|
+
}
|
|
9117
|
+
static isSafari() {
|
|
9118
|
+
return this.browser.getBrowserName() === BrowserName.SAFARI;
|
|
9119
|
+
}
|
|
9120
|
+
static isVersionGreaterThan(version) {
|
|
9121
|
+
const browserName = this.browser.getBrowserName();
|
|
9122
|
+
const checkTree = { [browserName]: `>${version}` };
|
|
9123
|
+
return this.browser.satisfies(checkTree);
|
|
9124
|
+
}
|
|
9125
|
+
static isVersionGreaterThanOrEqualTo(version) {
|
|
9126
|
+
const browserName = this.browser.getBrowserName();
|
|
9127
|
+
const checkTree = { [browserName]: `>=${version}` };
|
|
9128
|
+
return this.browser.satisfies(checkTree);
|
|
9129
|
+
}
|
|
9130
|
+
static isVersionLessThan(version) {
|
|
9131
|
+
const browserName = this.browser.getBrowserName();
|
|
9132
|
+
const checkTree = { [browserName]: `<${version}` };
|
|
9133
|
+
return this.browser.satisfies(checkTree);
|
|
9134
|
+
}
|
|
9135
|
+
static isVersionLessThanOrEqualTo(version) {
|
|
9136
|
+
const browserName = this.browser.getBrowserName();
|
|
9137
|
+
const checkTree = { [browserName]: `<=${version}` };
|
|
9138
|
+
return this.browser.satisfies(checkTree);
|
|
9139
|
+
}
|
|
9140
|
+
static isSubVersionOf(version) {
|
|
9141
|
+
const browserName = this.browser.getBrowserName();
|
|
9142
|
+
const checkTree = { [browserName]: `~${version}` };
|
|
9143
|
+
return this.browser.satisfies(checkTree);
|
|
9144
|
+
}
|
|
9090
9145
|
}
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9146
|
+
BrowserInfo.browser = Bowser.getParser(window.navigator.userAgent);
|
|
9147
|
+
|
|
9148
|
+
function getCpuInfo() {
|
|
9149
|
+
const cpuInfo = {};
|
|
9150
|
+
if (navigator.hardwareConcurrency) {
|
|
9151
|
+
cpuInfo.numLogicalCores = navigator.hardwareConcurrency;
|
|
9152
|
+
}
|
|
9153
|
+
return cpuInfo;
|
|
9095
9154
|
}
|
|
9096
9155
|
|
|
9156
|
+
var CapabilityState;
|
|
9157
|
+
(function (CapabilityState) {
|
|
9158
|
+
CapabilityState["NOT_CAPABLE"] = "not capable";
|
|
9159
|
+
CapabilityState["CAPABLE"] = "capable";
|
|
9160
|
+
CapabilityState["UNKNOWN"] = "unknown";
|
|
9161
|
+
})(CapabilityState || (CapabilityState = {}));
|
|
9162
|
+
getCpuInfo();
|
|
9163
|
+
|
|
9164
|
+
const simulcastMaxFrameSizes = {
|
|
9165
|
+
0: '240',
|
|
9166
|
+
1: '2304',
|
|
9167
|
+
2: '8160',
|
|
9168
|
+
};
|
|
9169
|
+
|
|
9097
9170
|
class JmpLine extends Line {
|
|
9098
9171
|
constructor(versions) {
|
|
9099
9172
|
super();
|
|
@@ -9178,18 +9251,18 @@ function matchMediaDescriptionsInAnswer(parsedOffer, parsedAnswer) {
|
|
|
9178
9251
|
parsedAnswer.session.groups = parsedOffer.session.groups;
|
|
9179
9252
|
parsedAnswer.media = parsedOffer.media.map((offerMediaDescription) => {
|
|
9180
9253
|
if (!offerMediaDescription.mid) {
|
|
9181
|
-
|
|
9254
|
+
logErrorAndThrow(WcmeErrorType.OFFER_ANSWER_MISMATCH, `Named media groups can only be set for audio.`);
|
|
9182
9255
|
}
|
|
9183
9256
|
const answerMediaDescription = parsedAnswer.media.find((m) => m.mid === offerMediaDescription.mid);
|
|
9184
9257
|
if (answerMediaDescription) {
|
|
9185
9258
|
return answerMediaDescription;
|
|
9186
9259
|
}
|
|
9187
9260
|
if (!(offerMediaDescription instanceof AvMediaDescription)) {
|
|
9188
|
-
|
|
9261
|
+
logErrorAndThrow(WcmeErrorType.OFFER_ANSWER_MISMATCH, `Answer is missing a non-AV media description for MID ${offerMediaDescription.mid}.`);
|
|
9189
9262
|
}
|
|
9190
9263
|
const startingMediaDescription = parsedAnswer.avMedia.find((m) => m.type === offerMediaDescription.type);
|
|
9191
9264
|
if (!startingMediaDescription) {
|
|
9192
|
-
|
|
9265
|
+
logErrorAndThrow(WcmeErrorType.OFFER_ANSWER_MISMATCH, `Answer has no media description of type ${offerMediaDescription.type}, can't generate synthetic answer media description for MID ${offerMediaDescription.mid}.`);
|
|
9193
9266
|
}
|
|
9194
9267
|
const fakeCorrespondingDescription = deepCopy(startingMediaDescription);
|
|
9195
9268
|
fakeCorrespondingDescription.mid = offerMediaDescription.mid;
|
|
@@ -9305,6 +9378,9 @@ class EgressSdpMunger {
|
|
|
9305
9378
|
mungeLocalDescription(mediaDescription, simulcastEnabled, rtxEnabled) {
|
|
9306
9379
|
var _a;
|
|
9307
9380
|
retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
|
|
9381
|
+
if (mediaDescription.codecs.size === 0) {
|
|
9382
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_MISSING_CODECS, `No codecs present in m-line with MID ${mediaDescription.mid} after filtering.`);
|
|
9383
|
+
}
|
|
9308
9384
|
mediaDescription.bandwidth = new BandwidthLine('TIAS', 20000000);
|
|
9309
9385
|
mediaDescription.rids = [];
|
|
9310
9386
|
mediaDescription.simulcast = undefined;
|
|
@@ -9320,12 +9396,12 @@ class EgressSdpMunger {
|
|
|
9320
9396
|
];
|
|
9321
9397
|
mediaDescription.ssrcGroups.forEach((sg) => {
|
|
9322
9398
|
if (!sg.ssrcs.every((ssrc) => ssrcs.includes(ssrc))) {
|
|
9323
|
-
|
|
9399
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_FAILED, 'SSRC present in SSRC groups is missing from SSRC lines.');
|
|
9324
9400
|
}
|
|
9325
9401
|
});
|
|
9326
9402
|
const rtxSsrcGroups = mediaDescription.ssrcGroups.filter((sg) => sg.semantics === 'FID');
|
|
9327
9403
|
if (rtxSsrcGroups.length && rtxSsrcGroups.length !== numStreams) {
|
|
9328
|
-
|
|
9404
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_FAILED, `Expected ${numStreams} RTX SSRC groups, got ${rtxSsrcGroups.length}.`);
|
|
9329
9405
|
}
|
|
9330
9406
|
rtxSsrcGroups.forEach((sg) => {
|
|
9331
9407
|
this.streamIds.push({
|
|
@@ -9337,12 +9413,12 @@ class EgressSdpMunger {
|
|
|
9337
9413
|
if (simulcastSsrcs) {
|
|
9338
9414
|
if (simulcastSsrcs.length !== numStreams ||
|
|
9339
9415
|
!this.streamIds.every((streamId) => simulcastSsrcs.includes(streamId.ssrc))) {
|
|
9340
|
-
|
|
9416
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_FAILED, 'SSRCs in simulcast SSRC group do not match primary SSRCs in RTX SSRC groups.');
|
|
9341
9417
|
}
|
|
9342
9418
|
this.streamIds.sort((a, b) => simulcastSsrcs.indexOf(a.ssrc) - simulcastSsrcs.indexOf(b.ssrc));
|
|
9343
9419
|
}
|
|
9344
9420
|
else if (rtxSsrcGroups.length > 1) {
|
|
9345
|
-
|
|
9421
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_FAILED, 'Multiple RTX SSRC groups but no simulcast SSRC group found.');
|
|
9346
9422
|
}
|
|
9347
9423
|
if (!this.streamIds.length) {
|
|
9348
9424
|
this.streamIds.push({ ssrc: ssrcs[0] });
|
|
@@ -9905,6 +9981,9 @@ class IngressSdpMunger {
|
|
|
9905
9981
|
}
|
|
9906
9982
|
mungeLocalDescription(mediaDescription) {
|
|
9907
9983
|
retainCodecs(mediaDescription, ['h264', 'opus', 'rtx']);
|
|
9984
|
+
if (mediaDescription.codecs.size === 0) {
|
|
9985
|
+
logErrorAndThrow(WcmeErrorType.SDP_MUNGE_MISSING_CODECS, `No codecs present in m-line with MID ${mediaDescription.mid} after filtering.`);
|
|
9986
|
+
}
|
|
9908
9987
|
mediaDescription.bandwidth = new BandwidthLine('TIAS', 20000000);
|
|
9909
9988
|
removeMidRidExtensions(mediaDescription);
|
|
9910
9989
|
}
|
|
@@ -13791,7 +13870,7 @@ function waterfall (tasks, callback) {
|
|
|
13791
13870
|
awaitify(waterfall);
|
|
13792
13871
|
|
|
13793
13872
|
function processTasks(task, finishedCallback) {
|
|
13794
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13873
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13795
13874
|
try {
|
|
13796
13875
|
yield task();
|
|
13797
13876
|
finishedCallback();
|
|
@@ -13838,7 +13917,7 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13838
13917
|
}
|
|
13839
13918
|
replaceSenderSource(stream) {
|
|
13840
13919
|
var _a, _b;
|
|
13841
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13920
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13842
13921
|
const trackOrNull = (_a = stream === null || stream === void 0 ? void 0 : stream.outputStream.getTracks()[0]) !== null && _a !== void 0 ? _a : null;
|
|
13843
13922
|
if (((_b = this.sender.track) === null || _b === void 0 ? void 0 : _b.id) !== (trackOrNull === null || trackOrNull === void 0 ? void 0 : trackOrNull.id)) {
|
|
13844
13923
|
yield this.sender.replaceTrack(trackOrNull);
|
|
@@ -13852,14 +13931,14 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13852
13931
|
});
|
|
13853
13932
|
}
|
|
13854
13933
|
handleTrackChange() {
|
|
13855
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13934
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13856
13935
|
if (this.requested) {
|
|
13857
13936
|
yield this.replaceSenderSource(this.publishedStream);
|
|
13858
13937
|
}
|
|
13859
13938
|
});
|
|
13860
13939
|
}
|
|
13861
13940
|
handleStreamConstraintsChange() {
|
|
13862
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13941
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13863
13942
|
yield this.updateSendParameters(this.requestedIdEncodingParamsMap);
|
|
13864
13943
|
});
|
|
13865
13944
|
}
|
|
@@ -13873,7 +13952,7 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13873
13952
|
const _super = Object.create(null, {
|
|
13874
13953
|
replaceTransceiver: { get: () => super.replaceTransceiver }
|
|
13875
13954
|
});
|
|
13876
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13955
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13877
13956
|
_super.replaceTransceiver.call(this, newRtcRtpTransceiver);
|
|
13878
13957
|
newRtcRtpTransceiver.direction = this.direction;
|
|
13879
13958
|
if (this.requested) {
|
|
@@ -13882,7 +13961,7 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13882
13961
|
});
|
|
13883
13962
|
}
|
|
13884
13963
|
replacePublishedStream(newStream) {
|
|
13885
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13964
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
13886
13965
|
const oldStream = this.publishedStream;
|
|
13887
13966
|
oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.OutputTrackChange, this.handleTrackChange);
|
|
13888
13967
|
oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
|
|
@@ -13905,7 +13984,7 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13905
13984
|
}
|
|
13906
13985
|
setNamedMediaGroups(namedMediaGroups) {
|
|
13907
13986
|
if (this.mediaType !== MediaType.AudioMain) {
|
|
13908
|
-
|
|
13987
|
+
logErrorAndThrow(WcmeErrorType.SET_NMG_FAILED, `Named media groups can only be set for audio.`);
|
|
13909
13988
|
}
|
|
13910
13989
|
this.namedMediaGroups = namedMediaGroups;
|
|
13911
13990
|
this.namedMediaGroupsChange.emit();
|
|
@@ -13930,8 +14009,8 @@ class SendOnlyTransceiver extends Transceiver {
|
|
|
13930
14009
|
return this.sender.getStats();
|
|
13931
14010
|
}
|
|
13932
14011
|
updateSendParameters(requestedIdEncodingParamsMap) {
|
|
13933
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
13934
|
-
return this.updateSendParametersQueue.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
14012
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14013
|
+
return this.updateSendParametersQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
13935
14014
|
const requested = requestedIdEncodingParamsMap.size > 0;
|
|
13936
14015
|
if (this.requested !== requested) {
|
|
13937
14016
|
yield this.replaceSenderSource(requested ? this.publishedStream : null);
|
|
@@ -14001,7 +14080,7 @@ class SendSlot {
|
|
|
14001
14080
|
this.sendTransceiver = sendTransceiver;
|
|
14002
14081
|
}
|
|
14003
14082
|
publishStream(stream) {
|
|
14004
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14083
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14005
14084
|
if (stream === this.sendTransceiver.publishedStream) {
|
|
14006
14085
|
return Promise.resolve();
|
|
14007
14086
|
}
|
|
@@ -14009,7 +14088,7 @@ class SendSlot {
|
|
|
14009
14088
|
});
|
|
14010
14089
|
}
|
|
14011
14090
|
unpublishStream() {
|
|
14012
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14091
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14013
14092
|
if (!this.sendTransceiver.publishedStream) {
|
|
14014
14093
|
return Promise.resolve();
|
|
14015
14094
|
}
|
|
@@ -14026,24 +14105,24 @@ class SendSlot {
|
|
|
14026
14105
|
this.sendTransceiver.active = active;
|
|
14027
14106
|
}
|
|
14028
14107
|
setCodecParameters(parameters) {
|
|
14029
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14108
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14030
14109
|
this.sendTransceiver.setCodecParameters(parameters);
|
|
14031
14110
|
});
|
|
14032
14111
|
}
|
|
14033
14112
|
deleteCodecParameters(parameters) {
|
|
14034
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14113
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14035
14114
|
this.sendTransceiver.deleteCodecParameters(parameters);
|
|
14036
14115
|
});
|
|
14037
14116
|
}
|
|
14038
14117
|
}
|
|
14039
14118
|
|
|
14040
14119
|
class StatsManager {
|
|
14041
|
-
constructor(statsGetter, statsPreprocessor = () => __awaiter(this, void 0, void 0, function* () { })) {
|
|
14120
|
+
constructor(statsGetter, statsPreprocessor = () => __awaiter$1(this, void 0, void 0, function* () { })) {
|
|
14042
14121
|
this.statsGetter = statsGetter;
|
|
14043
14122
|
this.statsPreProcessor = statsPreprocessor;
|
|
14044
14123
|
}
|
|
14045
14124
|
getStats() {
|
|
14046
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14125
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14047
14126
|
const statsReport = yield this.statsGetter();
|
|
14048
14127
|
const statsMap = new Map();
|
|
14049
14128
|
statsReport.forEach((stats, key) => statsMap.set(key, stats));
|
|
@@ -14053,7 +14132,7 @@ class StatsManager {
|
|
|
14053
14132
|
}
|
|
14054
14133
|
}
|
|
14055
14134
|
|
|
14056
|
-
const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14135
|
+
const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
14057
14136
|
const result = {
|
|
14058
14137
|
audio: {
|
|
14059
14138
|
senders: [],
|
|
@@ -14072,7 +14151,7 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
|
|
|
14072
14151
|
receivers: [],
|
|
14073
14152
|
},
|
|
14074
14153
|
};
|
|
14075
|
-
yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14154
|
+
yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
14076
14155
|
var _a;
|
|
14077
14156
|
const item = {
|
|
14078
14157
|
report: yield transceiver.getStats(),
|
|
@@ -14094,8 +14173,8 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
|
|
|
14094
14173
|
result.screenShareVideo.senders.push(item);
|
|
14095
14174
|
}
|
|
14096
14175
|
})));
|
|
14097
|
-
yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14098
|
-
return Promise.all(transceivers.map((t) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14176
|
+
yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
14177
|
+
return Promise.all(transceivers.map((t) => __awaiter$1(void 0, void 0, void 0, function* () {
|
|
14099
14178
|
var _b, _c;
|
|
14100
14179
|
const item = {
|
|
14101
14180
|
report: yield t.getStats(),
|
|
@@ -14315,7 +14394,7 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14315
14394
|
rsRequests.forEach(({ ids, policySpecificInfo, codecInfos, maxPayloadBitsPerSecond }) => {
|
|
14316
14395
|
var _a, _b, _c;
|
|
14317
14396
|
if (ids.length > 1) {
|
|
14318
|
-
|
|
14397
|
+
logErrorAndThrow(WcmeErrorType.INVALID_STREAM_REQUEST, `Stream request cannot have more than one ID.`);
|
|
14319
14398
|
}
|
|
14320
14399
|
if (ids.length === 0) {
|
|
14321
14400
|
return;
|
|
@@ -14476,9 +14555,9 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14476
14555
|
});
|
|
14477
14556
|
}
|
|
14478
14557
|
createReceiveSlot(mediaType) {
|
|
14479
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14558
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14480
14559
|
return new Promise((createReceiveSlotResolve) => {
|
|
14481
|
-
this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
14560
|
+
this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14482
14561
|
const rtcRtpTransceiver = this.pc.addTransceiver(toMediaStreamTrackKind(mediaType), {
|
|
14483
14562
|
direction: 'recvonly',
|
|
14484
14563
|
});
|
|
@@ -14517,19 +14596,19 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14517
14596
|
!receiverCodecs ||
|
|
14518
14597
|
senderCodecs.length === 0 ||
|
|
14519
14598
|
receiverCodecs.length === 0) {
|
|
14520
|
-
|
|
14599
|
+
logErrorAndThrow(WcmeErrorType.GET_PAYLOAD_TYPE_FAILED, `Sender codecs or receiver codecs is undefined or empty.`);
|
|
14521
14600
|
}
|
|
14522
14601
|
const senderCodec = senderCodecs[0];
|
|
14523
14602
|
const targetCodec = receiverCodecs.find((receiverCodec) => {
|
|
14524
14603
|
return areCodecsCompatible(senderCodec, receiverCodec);
|
|
14525
14604
|
});
|
|
14526
14605
|
if (!targetCodec || !targetCodec.pt) {
|
|
14527
|
-
|
|
14606
|
+
logErrorAndThrow(WcmeErrorType.GET_PAYLOAD_TYPE_FAILED, `Cannot find matching receiver codec for the given mediaType/mimeType.`);
|
|
14528
14607
|
}
|
|
14529
14608
|
return targetCodec.pt;
|
|
14530
14609
|
}
|
|
14531
14610
|
createOffer() {
|
|
14532
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14611
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14533
14612
|
if (!this.pc.getLocalDescription()) {
|
|
14534
14613
|
this.midPredictor.allocateMidForDatachannel();
|
|
14535
14614
|
}
|
|
@@ -14540,12 +14619,12 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14540
14619
|
}
|
|
14541
14620
|
const createOfferId = ++this.currentCreateOfferId;
|
|
14542
14621
|
return new Promise((createOfferResolve, createOfferReject) => {
|
|
14543
|
-
this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
14622
|
+
this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14544
14623
|
var _a;
|
|
14545
14624
|
try {
|
|
14546
14625
|
const offer = yield this.pc.createOffer();
|
|
14547
14626
|
if (!offer.sdp) {
|
|
14548
|
-
|
|
14627
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14549
14628
|
}
|
|
14550
14629
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14551
14630
|
yield this.pc.setLocalDescription(offer);
|
|
@@ -14568,13 +14647,13 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14568
14647
|
});
|
|
14569
14648
|
}
|
|
14570
14649
|
setAnswer(answer) {
|
|
14571
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14650
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14572
14651
|
const sdp = this.preProcessRemoteAnswer(answer);
|
|
14573
14652
|
if (!this.setAnswerResolve) {
|
|
14574
|
-
|
|
14653
|
+
logErrorAndThrow(WcmeErrorType.SET_ANSWER_FAILED, `Call to setAnswer without having previously called createOffer.`);
|
|
14575
14654
|
}
|
|
14576
14655
|
logger.info('calling this.pc.setRemoteDescription()');
|
|
14577
|
-
return this.pc.setRemoteDescription({ type: 'answer', sdp }).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
14656
|
+
return this.pc.setRemoteDescription({ type: 'answer', sdp }).then(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14578
14657
|
logger.info('this.pc.setRemoteDescription() resolved');
|
|
14579
14658
|
if (this.setAnswerResolve) {
|
|
14580
14659
|
this.setAnswerResolve();
|
|
@@ -14588,10 +14667,10 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14588
14667
|
}
|
|
14589
14668
|
doLocalOfferAnswer() {
|
|
14590
14669
|
var _a;
|
|
14591
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14670
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14592
14671
|
const offer = yield this.pc.createOffer();
|
|
14593
14672
|
if (!offer.sdp) {
|
|
14594
|
-
|
|
14673
|
+
logErrorAndThrow(WcmeErrorType.CREATE_OFFER_FAILED, 'SDP not found in offer.');
|
|
14595
14674
|
}
|
|
14596
14675
|
offer.sdp = this.preProcessLocalOffer(offer.sdp);
|
|
14597
14676
|
yield this.pc.setLocalDescription(offer);
|
|
@@ -14600,8 +14679,8 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14600
14679
|
});
|
|
14601
14680
|
}
|
|
14602
14681
|
queueLocalOfferAnswer() {
|
|
14603
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14604
|
-
return this.offerAnswerQueue.push(() => __awaiter(this, void 0, void 0, function* () {
|
|
14682
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14683
|
+
return this.offerAnswerQueue.push(() => __awaiter$1(this, void 0, void 0, function* () {
|
|
14605
14684
|
yield this.doLocalOfferAnswer();
|
|
14606
14685
|
}));
|
|
14607
14686
|
});
|
|
@@ -14683,21 +14762,21 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14683
14762
|
getSendTransceiverOrThrow(mediaType) {
|
|
14684
14763
|
const sendTransceiver = this.sendTransceivers.get(mediaType);
|
|
14685
14764
|
if (!sendTransceiver) {
|
|
14686
|
-
|
|
14765
|
+
logErrorAndThrow(WcmeErrorType.GET_TRANSCEIVER_FAILED, `Unable to find send transceiver for media type ${mediaType}.`);
|
|
14687
14766
|
}
|
|
14688
14767
|
return sendTransceiver;
|
|
14689
14768
|
}
|
|
14690
14769
|
getSendTransceiverByMidOrThrow(mid) {
|
|
14691
14770
|
const transceiver = [...this.sendTransceivers.values()].find((t) => t.mid === mid);
|
|
14692
14771
|
if (!transceiver) {
|
|
14693
|
-
|
|
14772
|
+
logErrorAndThrow(WcmeErrorType.GET_TRANSCEIVER_FAILED, `Unable to find send transceiver with MID ${mid}.`);
|
|
14694
14773
|
}
|
|
14695
14774
|
return transceiver;
|
|
14696
14775
|
}
|
|
14697
14776
|
getRecvTransceiverByMidOrThrow(mid) {
|
|
14698
14777
|
const transceiver = [...this.recvTransceivers.values()].flat().find((t) => t.mid === mid);
|
|
14699
14778
|
if (!transceiver) {
|
|
14700
|
-
|
|
14779
|
+
logErrorAndThrow(WcmeErrorType.GET_TRANSCEIVER_FAILED, `Unable to find recv transceiver with MID ${mid}.`);
|
|
14701
14780
|
}
|
|
14702
14781
|
return transceiver;
|
|
14703
14782
|
}
|
|
@@ -14784,13 +14863,13 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14784
14863
|
return this.statsManager.getStats();
|
|
14785
14864
|
}
|
|
14786
14865
|
getTransceiverStats() {
|
|
14787
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14866
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14788
14867
|
return organizeTransceiverStats(this.sendTransceivers, this.recvTransceivers);
|
|
14789
14868
|
});
|
|
14790
14869
|
}
|
|
14791
14870
|
preProcessStats(stats) {
|
|
14792
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14793
|
-
yield Promise.all([...this.sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter(this, void 0, void 0, function* () {
|
|
14871
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
14872
|
+
yield Promise.all([...this.sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(this, void 0, void 0, function* () {
|
|
14794
14873
|
(yield transceiver.getStats()).forEach((senderStats) => {
|
|
14795
14874
|
var _a;
|
|
14796
14875
|
if (senderStats.type === 'outbound-rtp') {
|
|
@@ -14811,8 +14890,8 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14811
14890
|
}
|
|
14812
14891
|
});
|
|
14813
14892
|
})));
|
|
14814
|
-
yield Promise.all([...this.recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter(this, void 0, void 0, function* () {
|
|
14815
|
-
yield Promise.all(transceivers.map((transceiver) => __awaiter(this, void 0, void 0, function* () {
|
|
14893
|
+
yield Promise.all([...this.recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(this, void 0, void 0, function* () {
|
|
14894
|
+
yield Promise.all(transceivers.map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
|
|
14816
14895
|
(yield transceiver.getStats()).forEach((receiverStats) => {
|
|
14817
14896
|
var _a;
|
|
14818
14897
|
if (receiverStats.type === 'inbound-rtp') {
|
|
@@ -14829,7 +14908,11 @@ class MultistreamConnection extends EventEmitter$2 {
|
|
|
14829
14908
|
});
|
|
14830
14909
|
}
|
|
14831
14910
|
attachMetricsObserver() {
|
|
14832
|
-
rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats));
|
|
14911
|
+
this.forceStatsReport = rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats)).forceStatsReport;
|
|
14912
|
+
}
|
|
14913
|
+
forceRtcMetricsCallback() {
|
|
14914
|
+
var _a;
|
|
14915
|
+
return (_a = this.forceStatsReport) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
14833
14916
|
}
|
|
14834
14917
|
setMetricsCallback(callback) {
|
|
14835
14918
|
this.metricsCallback = callback;
|
|
@@ -14864,5 +14947,5 @@ class StreamRequest {
|
|
|
14864
14947
|
}
|
|
14865
14948
|
}
|
|
14866
14949
|
|
|
14867
|
-
export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteStream, SendSlot, StreamEventNames, StreamRequest, WcmeError, Logger$2 as WebRtcCoreLogger, compareReceiveSlotIds, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices,
|
|
14950
|
+
export { ActiveSpeakerInfo, CodecInfo$1 as CodecInfo, ConnectionState, H264Codec, Logger$1 as JMPLogger, LocalCameraStream, LocalDisplayStream, LocalMicrophoneStream, LocalStream, LocalStreamEventNames, LocalSystemAudioStream, Logger, MediaCodecMimeType, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamConnection, MultistreamConnectionEventNames, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteStream, SendSlot, StreamEventNames, StreamRequest, WcmeError, WcmeErrorType, Logger$2 as WebRtcCoreLogger, WebrtcCoreError, WebrtcCoreErrorType, compareReceiveSlotIds, createCameraStream, createDisplayStream, createDisplayStreamWithAudio, createMicrophoneStream, getAudioInputDevices, getAudioOutputDevices, getDevices, getLogLevel, getMediaContent, getMediaFamily, getMediaType, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, logErrorAndThrow, setLogHandler, setLogLevel, setOnDeviceChangeHandler };
|
|
14868
14951
|
//# sourceMappingURL=index.js.map
|