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