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