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