@webex/internal-media-core 1.38.1 → 1.38.3
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 +1586 -1585
- package/dist/esm/index.js +1586 -1586
- package/dist/types/MediaConnection/MediaConnection.d.ts +18 -20
- package/dist/types/MediaConnection/MediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/MultistreamRoapMediaConnection.d.ts +0 -1
- package/dist/types/MediaConnection/MultistreamRoapMediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/RoapMediaConnection.d.ts +6 -11
- package/dist/types/MediaConnection/RoapMediaConnection.d.ts.map +1 -1
- package/dist/types/MediaConnection/logger.d.ts +2 -1
- package/dist/types/MediaConnection/logger.d.ts.map +1 -1
- package/dist/types/MediaConnection/roap.typegen.d.ts +52 -52
- package/dist/types/MediaConnection/roap.typegen.d.ts.map +1 -1
- package/dist/types/MediaConnection/utils.d.ts +2 -1
- package/dist/types/MediaConnection/utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -2691,1516 +2691,6 @@ var Error$1 = /*#__PURE__*/Object.freeze({
|
|
|
2691
2691
|
|
|
2692
2692
|
class EventEmitter$3 extends EventEmitter$4 {}
|
|
2693
2693
|
|
|
2694
|
-
var defaultLogger = {
|
|
2695
|
-
info: function info() {
|
|
2696
|
-
return console.info(...arguments);
|
|
2697
|
-
},
|
|
2698
|
-
log: function log() {
|
|
2699
|
-
return console.log(...arguments);
|
|
2700
|
-
},
|
|
2701
|
-
error: function error() {
|
|
2702
|
-
return console.error(...arguments);
|
|
2703
|
-
},
|
|
2704
|
-
warn: function warn() {
|
|
2705
|
-
return console.warn(...arguments);
|
|
2706
|
-
},
|
|
2707
|
-
trace: function trace() {
|
|
2708
|
-
return console.trace(...arguments);
|
|
2709
|
-
},
|
|
2710
|
-
debug: function debug() {
|
|
2711
|
-
return console.debug(...arguments);
|
|
2712
|
-
}
|
|
2713
|
-
};
|
|
2714
|
-
var currentLogger = defaultLogger;
|
|
2715
|
-
var setLogger = newLogger => {
|
|
2716
|
-
if (newLogger) {
|
|
2717
|
-
currentLogger = newLogger;
|
|
2718
|
-
} else {
|
|
2719
|
-
currentLogger = defaultLogger;
|
|
2720
|
-
}
|
|
2721
|
-
};
|
|
2722
|
-
var getLogger = () => currentLogger;
|
|
2723
|
-
var getErrorDescription = error => {
|
|
2724
|
-
return error ? error.stack ? "".concat(error.message, ": ").concat(error.stack) : "".concat(error) : '';
|
|
2725
|
-
};
|
|
2726
|
-
|
|
2727
|
-
var NUM$1 = '\\d+';
|
|
2728
|
-
var SDP_TOKEN$1 = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
|
|
2729
|
-
var ANY_NON_WS$1 = '\\S+';
|
|
2730
|
-
var SP$1 = '\\s';
|
|
2731
|
-
var REST$1 = '.+';
|
|
2732
|
-
class Line$1 {}
|
|
2733
|
-
var _a$5$1;
|
|
2734
|
-
class BandwidthLine$1 extends Line$1 {
|
|
2735
|
-
constructor(bandwidthType, bandwidth) {
|
|
2736
|
-
super();
|
|
2737
|
-
this.bandwidthType = bandwidthType;
|
|
2738
|
-
this.bandwidth = bandwidth;
|
|
2739
|
-
}
|
|
2740
|
-
static fromSdpLine(line) {
|
|
2741
|
-
if (!BandwidthLine$1.regex.test(line)) {
|
|
2742
|
-
return undefined;
|
|
2743
|
-
}
|
|
2744
|
-
var tokens = line.match(BandwidthLine$1.regex);
|
|
2745
|
-
var bandwidthType = tokens[1];
|
|
2746
|
-
var bandwidth = parseInt(tokens[2], 10);
|
|
2747
|
-
return new BandwidthLine$1(bandwidthType, bandwidth);
|
|
2748
|
-
}
|
|
2749
|
-
toSdpLine() {
|
|
2750
|
-
return "b=".concat(this.bandwidthType, ":").concat(this.bandwidth);
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
_a$5$1 = BandwidthLine$1;
|
|
2754
|
-
BandwidthLine$1.BW_TYPE_REGEX = 'CT|AS|TIAS';
|
|
2755
|
-
BandwidthLine$1.regex = new RegExp("^(".concat(_a$5$1.BW_TYPE_REGEX, "):(").concat(NUM$1, ")"));
|
|
2756
|
-
class BundleGroupLine$1 extends Line$1 {
|
|
2757
|
-
constructor(mids) {
|
|
2758
|
-
super();
|
|
2759
|
-
this.mids = mids;
|
|
2760
|
-
}
|
|
2761
|
-
static fromSdpLine(line) {
|
|
2762
|
-
if (!BundleGroupLine$1.regex.test(line)) {
|
|
2763
|
-
return undefined;
|
|
2764
|
-
}
|
|
2765
|
-
var tokens = line.match(BundleGroupLine$1.regex);
|
|
2766
|
-
var mids = tokens[1].split(' ');
|
|
2767
|
-
return new BundleGroupLine$1(mids);
|
|
2768
|
-
}
|
|
2769
|
-
toSdpLine() {
|
|
2770
|
-
return "a=group:BUNDLE ".concat(this.mids.join(' '));
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
BundleGroupLine$1.regex = new RegExp("^group:BUNDLE (".concat(REST$1, ")"));
|
|
2774
|
-
var _a$4$1;
|
|
2775
|
-
class CandidateLine$1 extends Line$1 {
|
|
2776
|
-
constructor(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions) {
|
|
2777
|
-
super();
|
|
2778
|
-
this.foundation = foundation;
|
|
2779
|
-
this.componentId = componentId;
|
|
2780
|
-
this.transport = transport;
|
|
2781
|
-
this.priority = priority;
|
|
2782
|
-
this.connectionAddress = connectionAddress;
|
|
2783
|
-
this.port = port;
|
|
2784
|
-
this.candidateType = candidateType;
|
|
2785
|
-
this.relAddr = relAddr;
|
|
2786
|
-
this.relPort = relPort;
|
|
2787
|
-
this.candidateExtensions = candidateExtensions;
|
|
2788
|
-
}
|
|
2789
|
-
static fromSdpLine(line) {
|
|
2790
|
-
if (!CandidateLine$1.regex.test(line)) {
|
|
2791
|
-
return undefined;
|
|
2792
|
-
}
|
|
2793
|
-
var tokens = line.match(CandidateLine$1.regex);
|
|
2794
|
-
var foundation = tokens[1];
|
|
2795
|
-
var componentId = parseInt(tokens[2], 10);
|
|
2796
|
-
var transport = tokens[3];
|
|
2797
|
-
var priority = parseInt(tokens[4], 10);
|
|
2798
|
-
var connectionAddress = tokens[5];
|
|
2799
|
-
var port = parseInt(tokens[6], 10);
|
|
2800
|
-
var candidateType = tokens[7];
|
|
2801
|
-
var relAddr = tokens[8];
|
|
2802
|
-
var relPort = tokens[9] ? parseInt(tokens[9], 10) : undefined;
|
|
2803
|
-
var candidateExtensions = tokens[10];
|
|
2804
|
-
return new CandidateLine$1(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions);
|
|
2805
|
-
}
|
|
2806
|
-
toSdpLine() {
|
|
2807
|
-
var str = '';
|
|
2808
|
-
str += "a=candidate:".concat(this.foundation, " ").concat(this.componentId, " ").concat(this.transport, " ").concat(this.priority, " ").concat(this.connectionAddress, " ").concat(this.port, " typ ").concat(this.candidateType);
|
|
2809
|
-
if (this.relAddr) {
|
|
2810
|
-
str += " raddr ".concat(this.relAddr);
|
|
2811
|
-
}
|
|
2812
|
-
if (this.relPort) {
|
|
2813
|
-
str += " rport ".concat(this.relPort);
|
|
2814
|
-
}
|
|
2815
|
-
if (this.candidateExtensions) {
|
|
2816
|
-
str += " ".concat(this.candidateExtensions);
|
|
2817
|
-
}
|
|
2818
|
-
return str;
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
_a$4$1 = CandidateLine$1;
|
|
2822
|
-
CandidateLine$1.ICE_CHARS = "[a-zA-Z0-9+/]+";
|
|
2823
|
-
CandidateLine$1.regex = new RegExp("^candidate:(".concat(_a$4$1.ICE_CHARS, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS$1, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS$1, ") (").concat(NUM$1, ") typ (").concat(ANY_NON_WS$1, ")(?: raddr (").concat(ANY_NON_WS$1, "))?(?: rport (").concat(NUM$1, "))?(?: (").concat(REST$1, "))?"));
|
|
2824
|
-
class ConnectionLine$1 extends Line$1 {
|
|
2825
|
-
constructor(netType, addrType, ipAddr) {
|
|
2826
|
-
super();
|
|
2827
|
-
this.netType = netType;
|
|
2828
|
-
this.addrType = addrType;
|
|
2829
|
-
this.ipAddr = ipAddr;
|
|
2830
|
-
}
|
|
2831
|
-
static fromSdpLine(line) {
|
|
2832
|
-
if (!ConnectionLine$1.regex.test(line)) {
|
|
2833
|
-
return undefined;
|
|
2834
|
-
}
|
|
2835
|
-
var tokens = line.match(ConnectionLine$1.regex);
|
|
2836
|
-
var netType = tokens[1];
|
|
2837
|
-
var addrType = tokens[2];
|
|
2838
|
-
var ipAddr = tokens[3];
|
|
2839
|
-
return new ConnectionLine$1(netType, addrType, ipAddr);
|
|
2840
|
-
}
|
|
2841
|
-
toSdpLine() {
|
|
2842
|
-
return "c=".concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
|
|
2843
|
-
}
|
|
2844
|
-
}
|
|
2845
|
-
ConnectionLine$1.regex = new RegExp("^(".concat(ANY_NON_WS$1, ") (").concat(ANY_NON_WS$1, ") (").concat(ANY_NON_WS$1, ")"));
|
|
2846
|
-
class ContentLine$1 extends Line$1 {
|
|
2847
|
-
constructor(values) {
|
|
2848
|
-
super();
|
|
2849
|
-
this.values = values;
|
|
2850
|
-
}
|
|
2851
|
-
static fromSdpLine(line) {
|
|
2852
|
-
if (!ContentLine$1.regex.test(line)) {
|
|
2853
|
-
return undefined;
|
|
2854
|
-
}
|
|
2855
|
-
var tokens = line.match(ContentLine$1.regex);
|
|
2856
|
-
var values = tokens[1].split(',');
|
|
2857
|
-
return new ContentLine$1(values);
|
|
2858
|
-
}
|
|
2859
|
-
toSdpLine() {
|
|
2860
|
-
return "a=content:".concat(this.values.join(','));
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
ContentLine$1.regex = new RegExp("^content:(".concat(REST$1, ")$"));
|
|
2864
|
-
class DirectionLine$1 extends Line$1 {
|
|
2865
|
-
constructor(direction) {
|
|
2866
|
-
super();
|
|
2867
|
-
this.direction = direction;
|
|
2868
|
-
}
|
|
2869
|
-
static fromSdpLine(line) {
|
|
2870
|
-
if (!DirectionLine$1.regex.test(line)) {
|
|
2871
|
-
return undefined;
|
|
2872
|
-
}
|
|
2873
|
-
var tokens = line.match(DirectionLine$1.regex);
|
|
2874
|
-
var direction = tokens[1];
|
|
2875
|
-
return new DirectionLine$1(direction);
|
|
2876
|
-
}
|
|
2877
|
-
toSdpLine() {
|
|
2878
|
-
return "a=".concat(this.direction);
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
DirectionLine$1.regex = /^(sendrecv|sendonly|recvonly|inactive)$/;
|
|
2882
|
-
var _a$3$1;
|
|
2883
|
-
class ExtMapLine$1 extends Line$1 {
|
|
2884
|
-
constructor(id, uri, direction, extensionAttributes) {
|
|
2885
|
-
super();
|
|
2886
|
-
this.id = id;
|
|
2887
|
-
this.uri = uri;
|
|
2888
|
-
this.direction = direction;
|
|
2889
|
-
this.extensionAttributes = extensionAttributes;
|
|
2890
|
-
}
|
|
2891
|
-
static fromSdpLine(line) {
|
|
2892
|
-
if (!ExtMapLine$1.regex.test(line)) {
|
|
2893
|
-
return undefined;
|
|
2894
|
-
}
|
|
2895
|
-
var tokens = line.match(ExtMapLine$1.regex);
|
|
2896
|
-
var id = parseInt(tokens[1], 10);
|
|
2897
|
-
var direction = tokens[2];
|
|
2898
|
-
var uri = tokens[3];
|
|
2899
|
-
var extensionAttributes = tokens[4];
|
|
2900
|
-
return new ExtMapLine$1(id, uri, direction, extensionAttributes);
|
|
2901
|
-
}
|
|
2902
|
-
toSdpLine() {
|
|
2903
|
-
var str = '';
|
|
2904
|
-
str += "a=extmap:".concat(this.id);
|
|
2905
|
-
if (this.direction) {
|
|
2906
|
-
str += "/".concat(this.direction);
|
|
2907
|
-
}
|
|
2908
|
-
str += " ".concat(this.uri);
|
|
2909
|
-
if (this.extensionAttributes) {
|
|
2910
|
-
str += " ".concat(this.extensionAttributes);
|
|
2911
|
-
}
|
|
2912
|
-
return str;
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
_a$3$1 = ExtMapLine$1;
|
|
2916
|
-
ExtMapLine$1.EXTMAP_DIRECTION = "sendonly|recvonly|sendrecv|inactive";
|
|
2917
|
-
ExtMapLine$1.regex = new RegExp("^extmap:(".concat(NUM$1, ")(?:/(").concat(_a$3$1.EXTMAP_DIRECTION, "))? (").concat(ANY_NON_WS$1, ")(?: (").concat(REST$1, "))?"));
|
|
2918
|
-
class FingerprintLine$1 extends Line$1 {
|
|
2919
|
-
constructor(fingerprint) {
|
|
2920
|
-
super();
|
|
2921
|
-
this.fingerprint = fingerprint;
|
|
2922
|
-
}
|
|
2923
|
-
static fromSdpLine(line) {
|
|
2924
|
-
if (!FingerprintLine$1.regex.test(line)) {
|
|
2925
|
-
return undefined;
|
|
2926
|
-
}
|
|
2927
|
-
var tokens = line.match(FingerprintLine$1.regex);
|
|
2928
|
-
var fingerprint = tokens[1];
|
|
2929
|
-
return new FingerprintLine$1(fingerprint);
|
|
2930
|
-
}
|
|
2931
|
-
toSdpLine() {
|
|
2932
|
-
return "a=fingerprint:".concat(this.fingerprint);
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
|
-
FingerprintLine$1.regex = new RegExp("^fingerprint:(".concat(REST$1, ")"));
|
|
2936
|
-
function parseFmtpParams$1(fmtpParams) {
|
|
2937
|
-
fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
|
|
2938
|
-
var fmtpObj = new Map();
|
|
2939
|
-
if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
|
|
2940
|
-
fmtpObj.set(fmtpParams, undefined);
|
|
2941
|
-
return fmtpObj;
|
|
2942
|
-
}
|
|
2943
|
-
fmtpParams.split(';').forEach(param => {
|
|
2944
|
-
var paramArr = param && param.split('=');
|
|
2945
|
-
if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
|
|
2946
|
-
throw new Error("Fmtp params is invalid with ".concat(fmtpParams));
|
|
2947
|
-
}
|
|
2948
|
-
fmtpObj.set(paramArr[0], paramArr[1]);
|
|
2949
|
-
});
|
|
2950
|
-
return fmtpObj;
|
|
2951
|
-
}
|
|
2952
|
-
class FmtpLine$1 extends Line$1 {
|
|
2953
|
-
constructor(payloadType, params) {
|
|
2954
|
-
super();
|
|
2955
|
-
this.payloadType = payloadType;
|
|
2956
|
-
this.params = params;
|
|
2957
|
-
}
|
|
2958
|
-
static fromSdpLine(line) {
|
|
2959
|
-
if (!FmtpLine$1.regex.test(line)) {
|
|
2960
|
-
return undefined;
|
|
2961
|
-
}
|
|
2962
|
-
var tokens = line.match(FmtpLine$1.regex);
|
|
2963
|
-
var payloadType = parseInt(tokens[1], 10);
|
|
2964
|
-
var params = tokens[2];
|
|
2965
|
-
return new FmtpLine$1(payloadType, parseFmtpParams$1(params));
|
|
2966
|
-
}
|
|
2967
|
-
toSdpLine() {
|
|
2968
|
-
var fmtParams = Array.from(this.params.keys()).map(key => {
|
|
2969
|
-
if (this.params.get(key) !== undefined) {
|
|
2970
|
-
return "".concat(key, "=").concat(this.params.get(key));
|
|
2971
|
-
}
|
|
2972
|
-
return "".concat(key);
|
|
2973
|
-
}).join(';');
|
|
2974
|
-
return "a=fmtp:".concat(this.payloadType, " ").concat(fmtParams);
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
FmtpLine$1.regex = new RegExp("^fmtp:(".concat(NUM$1, ") (").concat(REST$1, ")"));
|
|
2978
|
-
class IceOptionsLine$1 extends Line$1 {
|
|
2979
|
-
constructor(options) {
|
|
2980
|
-
super();
|
|
2981
|
-
this.options = options;
|
|
2982
|
-
}
|
|
2983
|
-
static fromSdpLine(line) {
|
|
2984
|
-
if (!IceOptionsLine$1.regex.test(line)) {
|
|
2985
|
-
return undefined;
|
|
2986
|
-
}
|
|
2987
|
-
var tokens = line.match(IceOptionsLine$1.regex);
|
|
2988
|
-
var options = tokens[1].split(' ');
|
|
2989
|
-
return new IceOptionsLine$1(options);
|
|
2990
|
-
}
|
|
2991
|
-
toSdpLine() {
|
|
2992
|
-
return "a=ice-options:".concat(this.options.join(' '));
|
|
2993
|
-
}
|
|
2994
|
-
}
|
|
2995
|
-
IceOptionsLine$1.regex = new RegExp("^ice-options:(".concat(REST$1, ")$"));
|
|
2996
|
-
class IcePwdLine$1 extends Line$1 {
|
|
2997
|
-
constructor(pwd) {
|
|
2998
|
-
super();
|
|
2999
|
-
this.pwd = pwd;
|
|
3000
|
-
}
|
|
3001
|
-
static fromSdpLine(line) {
|
|
3002
|
-
if (!IcePwdLine$1.regex.test(line)) {
|
|
3003
|
-
return undefined;
|
|
3004
|
-
}
|
|
3005
|
-
var tokens = line.match(IcePwdLine$1.regex);
|
|
3006
|
-
var pwd = tokens[1];
|
|
3007
|
-
return new IcePwdLine$1(pwd);
|
|
3008
|
-
}
|
|
3009
|
-
toSdpLine() {
|
|
3010
|
-
return "a=ice-pwd:".concat(this.pwd);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
IcePwdLine$1.regex = new RegExp("^ice-pwd:(".concat(ANY_NON_WS$1, ")$"));
|
|
3014
|
-
class IceUfragLine$1 extends Line$1 {
|
|
3015
|
-
constructor(ufrag) {
|
|
3016
|
-
super();
|
|
3017
|
-
this.ufrag = ufrag;
|
|
3018
|
-
}
|
|
3019
|
-
static fromSdpLine(line) {
|
|
3020
|
-
if (!IceUfragLine$1.regex.test(line)) {
|
|
3021
|
-
return undefined;
|
|
3022
|
-
}
|
|
3023
|
-
var tokens = line.match(IceUfragLine$1.regex);
|
|
3024
|
-
var ufrag = tokens[1];
|
|
3025
|
-
return new IceUfragLine$1(ufrag);
|
|
3026
|
-
}
|
|
3027
|
-
toSdpLine() {
|
|
3028
|
-
return "a=ice-ufrag:".concat(this.ufrag);
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
IceUfragLine$1.regex = new RegExp("^ice-ufrag:(".concat(ANY_NON_WS$1, ")$"));
|
|
3032
|
-
class MaxMessageSizeLine$1 extends Line$1 {
|
|
3033
|
-
constructor(maxMessageSize) {
|
|
3034
|
-
super();
|
|
3035
|
-
this.maxMessageSize = maxMessageSize;
|
|
3036
|
-
}
|
|
3037
|
-
static fromSdpLine(line) {
|
|
3038
|
-
if (!MaxMessageSizeLine$1.regex.test(line)) {
|
|
3039
|
-
return undefined;
|
|
3040
|
-
}
|
|
3041
|
-
var tokens = line.match(MaxMessageSizeLine$1.regex);
|
|
3042
|
-
var maxMessageSize = parseInt(tokens[1], 10);
|
|
3043
|
-
return new MaxMessageSizeLine$1(maxMessageSize);
|
|
3044
|
-
}
|
|
3045
|
-
toSdpLine() {
|
|
3046
|
-
return "a=max-message-size:".concat(this.maxMessageSize);
|
|
3047
|
-
}
|
|
3048
|
-
}
|
|
3049
|
-
MaxMessageSizeLine$1.regex = new RegExp("^max-message-size:(".concat(NUM$1, ")"));
|
|
3050
|
-
var _a$2$1;
|
|
3051
|
-
class MediaLine$1 extends Line$1 {
|
|
3052
|
-
constructor(type, port, protocol, formats) {
|
|
3053
|
-
super();
|
|
3054
|
-
this.type = type;
|
|
3055
|
-
this.port = port;
|
|
3056
|
-
this.protocol = protocol;
|
|
3057
|
-
this.formats = formats;
|
|
3058
|
-
}
|
|
3059
|
-
static fromSdpLine(line) {
|
|
3060
|
-
if (!MediaLine$1.regex.test(line)) {
|
|
3061
|
-
return undefined;
|
|
3062
|
-
}
|
|
3063
|
-
var tokens = line.match(MediaLine$1.regex);
|
|
3064
|
-
var type = tokens[1];
|
|
3065
|
-
var port = parseInt(tokens[2], 10);
|
|
3066
|
-
var protocol = tokens[3];
|
|
3067
|
-
var formats = tokens[4].split(' ');
|
|
3068
|
-
return new MediaLine$1(type, port, protocol, formats);
|
|
3069
|
-
}
|
|
3070
|
-
toSdpLine() {
|
|
3071
|
-
return "m=".concat(this.type, " ").concat(this.port, " ").concat(this.protocol, " ").concat(this.formats.join(' '));
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
_a$2$1 = MediaLine$1;
|
|
3075
|
-
MediaLine$1.MEDIA_TYPE = 'audio|video|application';
|
|
3076
|
-
MediaLine$1.regex = new RegExp("^(".concat(_a$2$1.MEDIA_TYPE, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS$1, ") (").concat(REST$1, ")"));
|
|
3077
|
-
class MidLine$1 extends Line$1 {
|
|
3078
|
-
constructor(mid) {
|
|
3079
|
-
super();
|
|
3080
|
-
this.mid = mid;
|
|
3081
|
-
}
|
|
3082
|
-
static fromSdpLine(line) {
|
|
3083
|
-
if (!MidLine$1.regex.test(line)) {
|
|
3084
|
-
return undefined;
|
|
3085
|
-
}
|
|
3086
|
-
var tokens = line.match(MidLine$1.regex);
|
|
3087
|
-
var mid = tokens[1];
|
|
3088
|
-
return new MidLine$1(mid);
|
|
3089
|
-
}
|
|
3090
|
-
toSdpLine() {
|
|
3091
|
-
return "a=mid:".concat(this.mid);
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
MidLine$1.regex = new RegExp("^mid:(".concat(ANY_NON_WS$1, ")$"));
|
|
3095
|
-
class OriginLine$1 extends Line$1 {
|
|
3096
|
-
constructor(username, sessionId, sessionVersion, netType, addrType, ipAddr) {
|
|
3097
|
-
super();
|
|
3098
|
-
this.username = username;
|
|
3099
|
-
this.sessionId = sessionId;
|
|
3100
|
-
this.sessionVersion = sessionVersion;
|
|
3101
|
-
this.netType = netType;
|
|
3102
|
-
this.addrType = addrType;
|
|
3103
|
-
this.ipAddr = ipAddr;
|
|
3104
|
-
}
|
|
3105
|
-
static fromSdpLine(line) {
|
|
3106
|
-
if (!OriginLine$1.regex.test(line)) {
|
|
3107
|
-
return undefined;
|
|
3108
|
-
}
|
|
3109
|
-
var tokens = line.match(OriginLine$1.regex);
|
|
3110
|
-
var username = tokens[1];
|
|
3111
|
-
var sessionId = tokens[2];
|
|
3112
|
-
var sessionVersion = parseInt(tokens[3], 10);
|
|
3113
|
-
var netType = tokens[4];
|
|
3114
|
-
var addrType = tokens[5];
|
|
3115
|
-
var ipAddr = tokens[6];
|
|
3116
|
-
return new OriginLine$1(username, sessionId, sessionVersion, netType, addrType, ipAddr);
|
|
3117
|
-
}
|
|
3118
|
-
toSdpLine() {
|
|
3119
|
-
return "o=".concat(this.username, " ").concat(this.sessionId, " ").concat(this.sessionVersion, " ").concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
OriginLine$1.regex = new RegExp("^(".concat(ANY_NON_WS$1, ") (").concat(ANY_NON_WS$1, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS$1, ") (").concat(ANY_NON_WS$1, ") (").concat(ANY_NON_WS$1, ")"));
|
|
3123
|
-
var _a$1$1;
|
|
3124
|
-
class RidLine$1 extends Line$1 {
|
|
3125
|
-
constructor(id, direction, params) {
|
|
3126
|
-
super();
|
|
3127
|
-
this.id = id;
|
|
3128
|
-
this.direction = direction;
|
|
3129
|
-
this.params = params;
|
|
3130
|
-
}
|
|
3131
|
-
static fromSdpLine(line) {
|
|
3132
|
-
if (!RidLine$1.regex.test(line)) {
|
|
3133
|
-
return undefined;
|
|
3134
|
-
}
|
|
3135
|
-
var tokens = line.match(RidLine$1.regex);
|
|
3136
|
-
var id = tokens[1];
|
|
3137
|
-
var direction = tokens[2];
|
|
3138
|
-
var params = tokens[3];
|
|
3139
|
-
return new RidLine$1(id, direction, params);
|
|
3140
|
-
}
|
|
3141
|
-
toSdpLine() {
|
|
3142
|
-
var str = '';
|
|
3143
|
-
str += "a=rid:".concat(this.id, " ").concat(this.direction);
|
|
3144
|
-
if (this.params) {
|
|
3145
|
-
str += " ".concat(this.params);
|
|
3146
|
-
}
|
|
3147
|
-
return str;
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
_a$1$1 = RidLine$1;
|
|
3151
|
-
RidLine$1.RID_ID = "[\\w-]+";
|
|
3152
|
-
RidLine$1.RID_DIRECTION = "\\bsend\\b|\\brecv\\b";
|
|
3153
|
-
RidLine$1.regex = new RegExp("^rid:(".concat(_a$1$1.RID_ID, ") (").concat(_a$1$1.RID_DIRECTION, ")(?:").concat(SP$1, "(").concat(REST$1, "))?"));
|
|
3154
|
-
class RtcpMuxLine$1 extends Line$1 {
|
|
3155
|
-
static fromSdpLine(line) {
|
|
3156
|
-
if (!RtcpMuxLine$1.regex.test(line)) {
|
|
3157
|
-
return undefined;
|
|
3158
|
-
}
|
|
3159
|
-
return new RtcpMuxLine$1();
|
|
3160
|
-
}
|
|
3161
|
-
toSdpLine() {
|
|
3162
|
-
return "a=rtcp-mux";
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
RtcpMuxLine$1.regex = /^rtcp-mux$/;
|
|
3166
|
-
class RtcpFbLine$1 extends Line$1 {
|
|
3167
|
-
constructor(payloadType, feedback) {
|
|
3168
|
-
super();
|
|
3169
|
-
this.payloadType = payloadType;
|
|
3170
|
-
this.feedback = feedback;
|
|
3171
|
-
}
|
|
3172
|
-
static fromSdpLine(line) {
|
|
3173
|
-
if (!RtcpFbLine$1.regex.test(line)) {
|
|
3174
|
-
return undefined;
|
|
3175
|
-
}
|
|
3176
|
-
var tokens = line.match(RtcpFbLine$1.regex);
|
|
3177
|
-
var payloadType = parseInt(tokens[1], 10);
|
|
3178
|
-
var feedback = tokens[2];
|
|
3179
|
-
return new RtcpFbLine$1(payloadType, feedback);
|
|
3180
|
-
}
|
|
3181
|
-
toSdpLine() {
|
|
3182
|
-
return "a=rtcp-fb:".concat(this.payloadType, " ").concat(this.feedback);
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
RtcpFbLine$1.regex = new RegExp("^rtcp-fb:(".concat(NUM$1, ") (").concat(REST$1, ")"));
|
|
3186
|
-
var _a$7;
|
|
3187
|
-
class RtpMapLine$1 extends Line$1 {
|
|
3188
|
-
constructor(payloadType, encodingName, clockRate, encodingParams) {
|
|
3189
|
-
super();
|
|
3190
|
-
this.payloadType = payloadType;
|
|
3191
|
-
this.encodingName = encodingName;
|
|
3192
|
-
this.clockRate = clockRate;
|
|
3193
|
-
this.encodingParams = encodingParams;
|
|
3194
|
-
}
|
|
3195
|
-
static fromSdpLine(line) {
|
|
3196
|
-
if (!RtpMapLine$1.regex.test(line)) {
|
|
3197
|
-
return undefined;
|
|
3198
|
-
}
|
|
3199
|
-
var tokens = line.match(RtpMapLine$1.regex);
|
|
3200
|
-
var payloadType = parseInt(tokens[1], 10);
|
|
3201
|
-
var encodingName = tokens[2];
|
|
3202
|
-
var clockRate = parseInt(tokens[3], 10);
|
|
3203
|
-
var encodingParams = tokens[4];
|
|
3204
|
-
return new RtpMapLine$1(payloadType, encodingName, clockRate, encodingParams);
|
|
3205
|
-
}
|
|
3206
|
-
toSdpLine() {
|
|
3207
|
-
var str = '';
|
|
3208
|
-
str += "a=rtpmap:".concat(this.payloadType, " ").concat(this.encodingName, "/").concat(this.clockRate);
|
|
3209
|
-
if (this.encodingParams) {
|
|
3210
|
-
str += "/".concat(this.encodingParams);
|
|
3211
|
-
}
|
|
3212
|
-
return str;
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3215
|
-
_a$7 = RtpMapLine$1;
|
|
3216
|
-
RtpMapLine$1.NON_SLASH_TOKEN = '[^\\s/]+';
|
|
3217
|
-
RtpMapLine$1.regex = new RegExp("^rtpmap:(".concat(NUM$1, ") (").concat(_a$7.NON_SLASH_TOKEN, ")/(").concat(_a$7.NON_SLASH_TOKEN, ")(?:/(").concat(_a$7.NON_SLASH_TOKEN, "))?"));
|
|
3218
|
-
class SctpPortLine$1 extends Line$1 {
|
|
3219
|
-
constructor(port) {
|
|
3220
|
-
super();
|
|
3221
|
-
this.port = port;
|
|
3222
|
-
}
|
|
3223
|
-
static fromSdpLine(line) {
|
|
3224
|
-
if (!SctpPortLine$1.regex.test(line)) {
|
|
3225
|
-
return undefined;
|
|
3226
|
-
}
|
|
3227
|
-
var tokens = line.match(SctpPortLine$1.regex);
|
|
3228
|
-
var port = parseInt(tokens[1], 10);
|
|
3229
|
-
return new SctpPortLine$1(port);
|
|
3230
|
-
}
|
|
3231
|
-
toSdpLine() {
|
|
3232
|
-
return "a=sctp-port:".concat(this.port);
|
|
3233
|
-
}
|
|
3234
|
-
}
|
|
3235
|
-
SctpPortLine$1.regex = new RegExp("^sctp-port:(".concat(NUM$1, ")"));
|
|
3236
|
-
class SessionInformationLine$1 extends Line$1 {
|
|
3237
|
-
constructor(info) {
|
|
3238
|
-
super();
|
|
3239
|
-
this.info = info;
|
|
3240
|
-
}
|
|
3241
|
-
static fromSdpLine(line) {
|
|
3242
|
-
if (!SessionInformationLine$1.regex.test(line)) {
|
|
3243
|
-
return undefined;
|
|
3244
|
-
}
|
|
3245
|
-
var tokens = line.match(SessionInformationLine$1.regex);
|
|
3246
|
-
var info = tokens[1];
|
|
3247
|
-
return new SessionInformationLine$1(info);
|
|
3248
|
-
}
|
|
3249
|
-
toSdpLine() {
|
|
3250
|
-
return "i=".concat(this.info);
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
SessionInformationLine$1.regex = new RegExp("(".concat(REST$1, ")"));
|
|
3254
|
-
class SessionNameLine$1 extends Line$1 {
|
|
3255
|
-
constructor(name) {
|
|
3256
|
-
super();
|
|
3257
|
-
this.name = name;
|
|
3258
|
-
}
|
|
3259
|
-
static fromSdpLine(line) {
|
|
3260
|
-
if (!SessionNameLine$1.regex.test(line)) {
|
|
3261
|
-
return undefined;
|
|
3262
|
-
}
|
|
3263
|
-
var tokens = line.match(SessionNameLine$1.regex);
|
|
3264
|
-
var name = tokens[1];
|
|
3265
|
-
return new SessionNameLine$1(name);
|
|
3266
|
-
}
|
|
3267
|
-
toSdpLine() {
|
|
3268
|
-
return "s=".concat(this.name);
|
|
3269
|
-
}
|
|
3270
|
-
}
|
|
3271
|
-
SessionNameLine$1.regex = new RegExp("^(".concat(REST$1, ")"));
|
|
3272
|
-
class SetupLine$1 extends Line$1 {
|
|
3273
|
-
constructor(setup) {
|
|
3274
|
-
super();
|
|
3275
|
-
this.setup = setup;
|
|
3276
|
-
}
|
|
3277
|
-
static fromSdpLine(line) {
|
|
3278
|
-
if (!SetupLine$1.regex.test(line)) {
|
|
3279
|
-
return undefined;
|
|
3280
|
-
}
|
|
3281
|
-
var tokens = line.match(SetupLine$1.regex);
|
|
3282
|
-
var setup = tokens[1];
|
|
3283
|
-
return new SetupLine$1(setup);
|
|
3284
|
-
}
|
|
3285
|
-
toSdpLine() {
|
|
3286
|
-
return "a=setup:".concat(this.setup);
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
SetupLine$1.regex = /^setup:(actpass|active|passive)$/;
|
|
3290
|
-
class SimulcastLayer$1 {
|
|
3291
|
-
constructor(id, paused) {
|
|
3292
|
-
this.id = id;
|
|
3293
|
-
this.paused = paused;
|
|
3294
|
-
}
|
|
3295
|
-
toString() {
|
|
3296
|
-
return this.paused ? "~".concat(this.id) : this.id;
|
|
3297
|
-
}
|
|
3298
|
-
}
|
|
3299
|
-
class SimulcastLayerList$1 {
|
|
3300
|
-
constructor() {
|
|
3301
|
-
this.layers = [];
|
|
3302
|
-
}
|
|
3303
|
-
addLayer(layer) {
|
|
3304
|
-
this.layers.push([layer]);
|
|
3305
|
-
}
|
|
3306
|
-
addLayerWithAlternatives(alternatives) {
|
|
3307
|
-
this.layers.push(alternatives);
|
|
3308
|
-
}
|
|
3309
|
-
get length() {
|
|
3310
|
-
return this.layers.length;
|
|
3311
|
-
}
|
|
3312
|
-
get(index) {
|
|
3313
|
-
return this.layers[index];
|
|
3314
|
-
}
|
|
3315
|
-
static fromString(str) {
|
|
3316
|
-
var layerList = new SimulcastLayerList$1();
|
|
3317
|
-
var tokens = str.split(';');
|
|
3318
|
-
if (tokens.length === 1 && !tokens[0].trim()) {
|
|
3319
|
-
throw new Error('simulcast stream list empty');
|
|
3320
|
-
}
|
|
3321
|
-
tokens.forEach(token => {
|
|
3322
|
-
if (!token) {
|
|
3323
|
-
throw new Error('simulcast layer list empty');
|
|
3324
|
-
}
|
|
3325
|
-
var ridTokens = token.split(',');
|
|
3326
|
-
var layers = [];
|
|
3327
|
-
ridTokens.forEach(ridToken => {
|
|
3328
|
-
if (!ridToken || ridToken === '~') {
|
|
3329
|
-
throw new Error('rid empty');
|
|
3330
|
-
}
|
|
3331
|
-
var paused = ridToken[0] === '~';
|
|
3332
|
-
var rid = paused ? ridToken.substring(1) : ridToken;
|
|
3333
|
-
layers.push(new SimulcastLayer$1(rid, paused));
|
|
3334
|
-
});
|
|
3335
|
-
layerList.addLayerWithAlternatives(layers);
|
|
3336
|
-
});
|
|
3337
|
-
return layerList;
|
|
3338
|
-
}
|
|
3339
|
-
toString() {
|
|
3340
|
-
return this.layers.map(altArray => altArray.map(v => v.toString()).join(',')).join(';');
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
class SimulcastLine$1 extends Line$1 {
|
|
3344
|
-
constructor(sendLayers, recvLayers) {
|
|
3345
|
-
super();
|
|
3346
|
-
this.sendLayers = sendLayers;
|
|
3347
|
-
this.recvLayers = recvLayers;
|
|
3348
|
-
}
|
|
3349
|
-
static fromSdpLine(line) {
|
|
3350
|
-
if (!SimulcastLine$1.regex.test(line)) {
|
|
3351
|
-
return undefined;
|
|
3352
|
-
}
|
|
3353
|
-
var tokens = line.match(SimulcastLine$1.regex);
|
|
3354
|
-
var bidirectional = tokens[3] && tokens[4];
|
|
3355
|
-
var firstDirection = tokens[1];
|
|
3356
|
-
var layerList1 = SimulcastLayerList$1.fromString(tokens[2]);
|
|
3357
|
-
var layerList2 = new SimulcastLayerList$1();
|
|
3358
|
-
if (bidirectional) {
|
|
3359
|
-
var secondDirection = tokens[3];
|
|
3360
|
-
if (firstDirection === secondDirection) {
|
|
3361
|
-
return undefined;
|
|
3362
|
-
}
|
|
3363
|
-
layerList2 = SimulcastLayerList$1.fromString(tokens[4]);
|
|
3364
|
-
}
|
|
3365
|
-
var sendLayerList;
|
|
3366
|
-
var recvLayerList;
|
|
3367
|
-
if (firstDirection === 'send') {
|
|
3368
|
-
sendLayerList = layerList1;
|
|
3369
|
-
recvLayerList = layerList2;
|
|
3370
|
-
} else {
|
|
3371
|
-
sendLayerList = layerList2;
|
|
3372
|
-
recvLayerList = layerList1;
|
|
3373
|
-
}
|
|
3374
|
-
return new SimulcastLine$1(sendLayerList, recvLayerList);
|
|
3375
|
-
}
|
|
3376
|
-
toSdpLine() {
|
|
3377
|
-
var str = 'a=simulcast:';
|
|
3378
|
-
if (this.sendLayers.length) {
|
|
3379
|
-
str += "send ".concat(this.sendLayers.toString());
|
|
3380
|
-
if (this.recvLayers.length) {
|
|
3381
|
-
str += " ";
|
|
3382
|
-
}
|
|
3383
|
-
}
|
|
3384
|
-
if (this.recvLayers.length) {
|
|
3385
|
-
str += "recv ".concat(this.recvLayers.toString());
|
|
3386
|
-
}
|
|
3387
|
-
return str;
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
SimulcastLine$1.regex = new RegExp("^simulcast:(send|recv) (".concat(ANY_NON_WS$1, ")(?: (send|recv) (").concat(ANY_NON_WS$1, "))?"));
|
|
3391
|
-
class SsrcLine$1 extends Line$1 {
|
|
3392
|
-
constructor(ssrcId, attribute) {
|
|
3393
|
-
var attributeValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
3394
|
-
var attributeData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
3395
|
-
super();
|
|
3396
|
-
this.ssrcId = ssrcId;
|
|
3397
|
-
this.attribute = attribute;
|
|
3398
|
-
this.attributeValue = attributeValue;
|
|
3399
|
-
this.attributeData = attributeData;
|
|
3400
|
-
}
|
|
3401
|
-
static fromSdpLine(line) {
|
|
3402
|
-
if (!SsrcLine$1.regex.test(line)) {
|
|
3403
|
-
return undefined;
|
|
3404
|
-
}
|
|
3405
|
-
var tokens = line.match(SsrcLine$1.regex);
|
|
3406
|
-
var ssrcId = parseInt(tokens[1], 10);
|
|
3407
|
-
var attribute = tokens[2];
|
|
3408
|
-
var attributeValue = tokens[3];
|
|
3409
|
-
var attributeData = tokens[4];
|
|
3410
|
-
return new SsrcLine$1(ssrcId, attribute, attributeValue, attributeData);
|
|
3411
|
-
}
|
|
3412
|
-
toSdpLine() {
|
|
3413
|
-
var str = "a=ssrc:".concat(this.ssrcId, " ").concat(this.attribute);
|
|
3414
|
-
if (this.attributeValue) {
|
|
3415
|
-
str += ":".concat(this.attributeValue);
|
|
3416
|
-
}
|
|
3417
|
-
if (this.attributeData) {
|
|
3418
|
-
str += " ".concat(this.attributeData);
|
|
3419
|
-
}
|
|
3420
|
-
return str;
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3423
|
-
SsrcLine$1.regex = new RegExp("^ssrc:(".concat(NUM$1, ") (").concat(SDP_TOKEN$1, ")(?::(").concat(SDP_TOKEN$1, ")?(?: (").concat(ANY_NON_WS$1, "))?)?$"));
|
|
3424
|
-
class SsrcGroupLine$1 extends Line$1 {
|
|
3425
|
-
constructor(semantics, ssrcs) {
|
|
3426
|
-
super();
|
|
3427
|
-
this.semantics = semantics;
|
|
3428
|
-
this.ssrcs = ssrcs;
|
|
3429
|
-
}
|
|
3430
|
-
static fromSdpLine(line) {
|
|
3431
|
-
if (!SsrcGroupLine$1.regex.test(line)) {
|
|
3432
|
-
return undefined;
|
|
3433
|
-
}
|
|
3434
|
-
var tokens = line.match(SsrcGroupLine$1.regex);
|
|
3435
|
-
var semantics = tokens[1];
|
|
3436
|
-
var ssrcs = tokens[2].split(' ').map(ssrcStr => parseInt(ssrcStr, 10));
|
|
3437
|
-
return new SsrcGroupLine$1(semantics, ssrcs);
|
|
3438
|
-
}
|
|
3439
|
-
toSdpLine() {
|
|
3440
|
-
return "a=ssrc-group:".concat(this.semantics, " ").concat(this.ssrcs.join(' '));
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
|
-
SsrcGroupLine$1.regex = new RegExp("^ssrc-group:(SIM|FID|FEC) ((?:".concat(NUM$1).concat(SP$1, "*)+)"));
|
|
3444
|
-
class TimingLine$1 extends Line$1 {
|
|
3445
|
-
constructor(startTime, stopTime) {
|
|
3446
|
-
super();
|
|
3447
|
-
this.startTime = startTime;
|
|
3448
|
-
this.stopTime = stopTime;
|
|
3449
|
-
}
|
|
3450
|
-
static fromSdpLine(line) {
|
|
3451
|
-
if (!TimingLine$1.regex.test(line)) {
|
|
3452
|
-
return undefined;
|
|
3453
|
-
}
|
|
3454
|
-
var tokens = line.match(TimingLine$1.regex);
|
|
3455
|
-
var startTime = parseInt(tokens[1], 10);
|
|
3456
|
-
var stopTime = parseInt(tokens[2], 10);
|
|
3457
|
-
return new TimingLine$1(startTime, stopTime);
|
|
3458
|
-
}
|
|
3459
|
-
toSdpLine() {
|
|
3460
|
-
return "t=".concat(this.startTime, " ").concat(this.stopTime);
|
|
3461
|
-
}
|
|
3462
|
-
}
|
|
3463
|
-
TimingLine$1.regex = new RegExp("^(".concat(NUM$1, ") (").concat(NUM$1, ")"));
|
|
3464
|
-
class VersionLine$1 extends Line$1 {
|
|
3465
|
-
constructor(version) {
|
|
3466
|
-
super();
|
|
3467
|
-
this.version = version;
|
|
3468
|
-
}
|
|
3469
|
-
static fromSdpLine(line) {
|
|
3470
|
-
if (!VersionLine$1.regex.test(line)) {
|
|
3471
|
-
return undefined;
|
|
3472
|
-
}
|
|
3473
|
-
var tokens = line.match(VersionLine$1.regex);
|
|
3474
|
-
var version = parseInt(tokens[1], 10);
|
|
3475
|
-
return new VersionLine$1(version);
|
|
3476
|
-
}
|
|
3477
|
-
toSdpLine() {
|
|
3478
|
-
return "v=".concat(this.version);
|
|
3479
|
-
}
|
|
3480
|
-
}
|
|
3481
|
-
VersionLine$1.regex = new RegExp("^(".concat(NUM$1, ")$"));
|
|
3482
|
-
class UnknownLine$1 extends Line$1 {
|
|
3483
|
-
constructor(value) {
|
|
3484
|
-
super();
|
|
3485
|
-
this.value = value;
|
|
3486
|
-
}
|
|
3487
|
-
static fromSdpLine(line) {
|
|
3488
|
-
var tokens = line.match(UnknownLine$1.regex);
|
|
3489
|
-
var value = tokens[1];
|
|
3490
|
-
return new UnknownLine$1(value);
|
|
3491
|
-
}
|
|
3492
|
-
toSdpLine() {
|
|
3493
|
-
return "".concat(this.value);
|
|
3494
|
-
}
|
|
3495
|
-
}
|
|
3496
|
-
UnknownLine$1.regex = new RegExp("(".concat(REST$1, ")"));
|
|
3497
|
-
class IceInfo$1 {
|
|
3498
|
-
constructor() {
|
|
3499
|
-
this.candidates = [];
|
|
3500
|
-
}
|
|
3501
|
-
addLine(line) {
|
|
3502
|
-
if (line instanceof IceUfragLine$1) {
|
|
3503
|
-
this.ufrag = line;
|
|
3504
|
-
return true;
|
|
3505
|
-
}
|
|
3506
|
-
if (line instanceof IcePwdLine$1) {
|
|
3507
|
-
this.pwd = line;
|
|
3508
|
-
return true;
|
|
3509
|
-
}
|
|
3510
|
-
if (line instanceof IceOptionsLine$1) {
|
|
3511
|
-
this.options = line;
|
|
3512
|
-
return true;
|
|
3513
|
-
}
|
|
3514
|
-
if (line instanceof CandidateLine$1) {
|
|
3515
|
-
this.candidates.push(line);
|
|
3516
|
-
return true;
|
|
3517
|
-
}
|
|
3518
|
-
return false;
|
|
3519
|
-
}
|
|
3520
|
-
toLines() {
|
|
3521
|
-
var lines = [];
|
|
3522
|
-
if (this.ufrag) {
|
|
3523
|
-
lines.push(this.ufrag);
|
|
3524
|
-
}
|
|
3525
|
-
if (this.pwd) {
|
|
3526
|
-
lines.push(this.pwd);
|
|
3527
|
-
}
|
|
3528
|
-
if (this.options) {
|
|
3529
|
-
lines.push(this.options);
|
|
3530
|
-
}
|
|
3531
|
-
this.candidates.forEach(candidate => lines.push(candidate));
|
|
3532
|
-
return lines;
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
|
-
class MediaDescription$1 {
|
|
3536
|
-
constructor(type, port, protocol) {
|
|
3537
|
-
this.iceInfo = new IceInfo$1();
|
|
3538
|
-
this.otherLines = [];
|
|
3539
|
-
this.type = type;
|
|
3540
|
-
this.port = port;
|
|
3541
|
-
this.protocol = protocol;
|
|
3542
|
-
}
|
|
3543
|
-
findOtherLine(ty) {
|
|
3544
|
-
return this.otherLines.find(line => line instanceof ty);
|
|
3545
|
-
}
|
|
3546
|
-
addLine(line) {
|
|
3547
|
-
if (line instanceof BundleGroupLine$1) {
|
|
3548
|
-
throw new Error("Error: bundle group line not allowed in media description");
|
|
3549
|
-
}
|
|
3550
|
-
if (line instanceof BandwidthLine$1) {
|
|
3551
|
-
this.bandwidth = line;
|
|
3552
|
-
return true;
|
|
3553
|
-
}
|
|
3554
|
-
if (line instanceof MidLine$1) {
|
|
3555
|
-
this.mid = line.mid;
|
|
3556
|
-
return true;
|
|
3557
|
-
}
|
|
3558
|
-
if (line instanceof FingerprintLine$1) {
|
|
3559
|
-
this.fingerprint = line.fingerprint;
|
|
3560
|
-
return true;
|
|
3561
|
-
}
|
|
3562
|
-
if (line instanceof SetupLine$1) {
|
|
3563
|
-
this.setup = line.setup;
|
|
3564
|
-
return true;
|
|
3565
|
-
}
|
|
3566
|
-
if (line instanceof ConnectionLine$1) {
|
|
3567
|
-
this.connection = line;
|
|
3568
|
-
return true;
|
|
3569
|
-
}
|
|
3570
|
-
if (line instanceof ContentLine$1) {
|
|
3571
|
-
this.content = line;
|
|
3572
|
-
return true;
|
|
3573
|
-
}
|
|
3574
|
-
return this.iceInfo.addLine(line);
|
|
3575
|
-
}
|
|
3576
|
-
}
|
|
3577
|
-
class ApplicationMediaDescription$1 extends MediaDescription$1 {
|
|
3578
|
-
constructor(mediaLine) {
|
|
3579
|
-
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
3580
|
-
this.fmts = [];
|
|
3581
|
-
this.fmts = mediaLine.formats;
|
|
3582
|
-
}
|
|
3583
|
-
toLines() {
|
|
3584
|
-
var lines = [];
|
|
3585
|
-
lines.push(new MediaLine$1(this.type, this.port, this.protocol, this.fmts));
|
|
3586
|
-
if (this.connection) {
|
|
3587
|
-
lines.push(this.connection);
|
|
3588
|
-
}
|
|
3589
|
-
if (this.bandwidth) {
|
|
3590
|
-
lines.push(this.bandwidth);
|
|
3591
|
-
}
|
|
3592
|
-
lines.push(...this.iceInfo.toLines());
|
|
3593
|
-
if (this.fingerprint) {
|
|
3594
|
-
lines.push(new FingerprintLine$1(this.fingerprint));
|
|
3595
|
-
}
|
|
3596
|
-
if (this.setup) {
|
|
3597
|
-
lines.push(new SetupLine$1(this.setup));
|
|
3598
|
-
}
|
|
3599
|
-
if (this.mid) {
|
|
3600
|
-
lines.push(new MidLine$1(this.mid));
|
|
3601
|
-
}
|
|
3602
|
-
if (this.content) {
|
|
3603
|
-
lines.push(this.content);
|
|
3604
|
-
}
|
|
3605
|
-
if (this.sctpPort) {
|
|
3606
|
-
lines.push(new SctpPortLine$1(this.sctpPort));
|
|
3607
|
-
}
|
|
3608
|
-
if (this.maxMessageSize) {
|
|
3609
|
-
lines.push(new MaxMessageSizeLine$1(this.maxMessageSize));
|
|
3610
|
-
}
|
|
3611
|
-
lines.push(...this.otherLines);
|
|
3612
|
-
return lines;
|
|
3613
|
-
}
|
|
3614
|
-
addLine(line) {
|
|
3615
|
-
if (super.addLine(line)) {
|
|
3616
|
-
return true;
|
|
3617
|
-
}
|
|
3618
|
-
if (line instanceof MediaLine$1) {
|
|
3619
|
-
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
3620
|
-
}
|
|
3621
|
-
if (line instanceof SctpPortLine$1) {
|
|
3622
|
-
this.sctpPort = line.port;
|
|
3623
|
-
return true;
|
|
3624
|
-
}
|
|
3625
|
-
if (line instanceof MaxMessageSizeLine$1) {
|
|
3626
|
-
this.maxMessageSize = line.maxMessageSize;
|
|
3627
|
-
return true;
|
|
3628
|
-
}
|
|
3629
|
-
this.otherLines.push(line);
|
|
3630
|
-
return true;
|
|
3631
|
-
}
|
|
3632
|
-
}
|
|
3633
|
-
class CodecInfo$2 {
|
|
3634
|
-
constructor(pt) {
|
|
3635
|
-
this.fmtParams = new Map();
|
|
3636
|
-
this.feedback = [];
|
|
3637
|
-
this.pt = pt;
|
|
3638
|
-
}
|
|
3639
|
-
addLine(line) {
|
|
3640
|
-
if (line instanceof RtpMapLine$1) {
|
|
3641
|
-
this.name = line.encodingName;
|
|
3642
|
-
this.clockRate = line.clockRate;
|
|
3643
|
-
this.encodingParams = line.encodingParams;
|
|
3644
|
-
return true;
|
|
3645
|
-
}
|
|
3646
|
-
if (line instanceof FmtpLine$1) {
|
|
3647
|
-
this.fmtParams = new Map([...Array.from(this.fmtParams.entries()), ...Array.from(line.params.entries())]);
|
|
3648
|
-
if (line.params.has('apt')) {
|
|
3649
|
-
var apt = line.params.get('apt');
|
|
3650
|
-
this.primaryCodecPt = parseInt(apt, 10);
|
|
3651
|
-
}
|
|
3652
|
-
return true;
|
|
3653
|
-
}
|
|
3654
|
-
if (line instanceof RtcpFbLine$1) {
|
|
3655
|
-
this.feedback.push(line.feedback);
|
|
3656
|
-
return true;
|
|
3657
|
-
}
|
|
3658
|
-
return false;
|
|
3659
|
-
}
|
|
3660
|
-
toLines() {
|
|
3661
|
-
var lines = [];
|
|
3662
|
-
if (this.name && this.clockRate) {
|
|
3663
|
-
lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
|
|
3664
|
-
}
|
|
3665
|
-
this.feedback.forEach(fb => {
|
|
3666
|
-
lines.push(new RtcpFbLine$1(this.pt, fb));
|
|
3667
|
-
});
|
|
3668
|
-
if (this.fmtParams.size > 0) {
|
|
3669
|
-
lines.push(new FmtpLine$1(this.pt, this.fmtParams));
|
|
3670
|
-
}
|
|
3671
|
-
return lines;
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
class AvMediaDescription$1 extends MediaDescription$1 {
|
|
3675
|
-
constructor(mediaLine) {
|
|
3676
|
-
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
3677
|
-
this.pts = [];
|
|
3678
|
-
this.extMaps = [];
|
|
3679
|
-
this.rids = [];
|
|
3680
|
-
this.codecs = new Map();
|
|
3681
|
-
this.rtcpMux = false;
|
|
3682
|
-
this.ssrcs = [];
|
|
3683
|
-
this.ssrcGroups = [];
|
|
3684
|
-
this.pts = mediaLine.formats.map(fmt => {
|
|
3685
|
-
return parseInt(fmt, 10);
|
|
3686
|
-
});
|
|
3687
|
-
this.pts.forEach(pt => this.codecs.set(pt, new CodecInfo$2(pt)));
|
|
3688
|
-
}
|
|
3689
|
-
toLines() {
|
|
3690
|
-
var lines = [];
|
|
3691
|
-
lines.push(new MediaLine$1(this.type, this.port, this.protocol, this.pts.map(pt => "".concat(pt))));
|
|
3692
|
-
if (this.connection) {
|
|
3693
|
-
lines.push(this.connection);
|
|
3694
|
-
}
|
|
3695
|
-
if (this.bandwidth) {
|
|
3696
|
-
lines.push(this.bandwidth);
|
|
3697
|
-
}
|
|
3698
|
-
lines.push(...this.iceInfo.toLines());
|
|
3699
|
-
if (this.fingerprint) {
|
|
3700
|
-
lines.push(new FingerprintLine$1(this.fingerprint));
|
|
3701
|
-
}
|
|
3702
|
-
if (this.setup) {
|
|
3703
|
-
lines.push(new SetupLine$1(this.setup));
|
|
3704
|
-
}
|
|
3705
|
-
if (this.mid) {
|
|
3706
|
-
lines.push(new MidLine$1(this.mid));
|
|
3707
|
-
}
|
|
3708
|
-
if (this.rtcpMux) {
|
|
3709
|
-
lines.push(new RtcpMuxLine$1());
|
|
3710
|
-
}
|
|
3711
|
-
if (this.content) {
|
|
3712
|
-
lines.push(this.content);
|
|
3713
|
-
}
|
|
3714
|
-
this.extMaps.forEach(extMap => lines.push(extMap));
|
|
3715
|
-
this.rids.forEach(rid => lines.push(rid));
|
|
3716
|
-
if (this.simulcast) {
|
|
3717
|
-
lines.push(this.simulcast);
|
|
3718
|
-
}
|
|
3719
|
-
if (this.direction) {
|
|
3720
|
-
lines.push(new DirectionLine$1(this.direction));
|
|
3721
|
-
}
|
|
3722
|
-
this.codecs.forEach(codec => lines.push(...codec.toLines()));
|
|
3723
|
-
lines.push(...this.ssrcs);
|
|
3724
|
-
lines.push(...this.ssrcGroups);
|
|
3725
|
-
lines.push(...this.otherLines);
|
|
3726
|
-
return lines;
|
|
3727
|
-
}
|
|
3728
|
-
addLine(line) {
|
|
3729
|
-
if (super.addLine(line)) {
|
|
3730
|
-
return true;
|
|
3731
|
-
}
|
|
3732
|
-
if (line instanceof MediaLine$1) {
|
|
3733
|
-
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
3734
|
-
}
|
|
3735
|
-
if (line instanceof DirectionLine$1) {
|
|
3736
|
-
this.direction = line.direction;
|
|
3737
|
-
return true;
|
|
3738
|
-
}
|
|
3739
|
-
if (line instanceof ExtMapLine$1) {
|
|
3740
|
-
this.extMaps.push(line);
|
|
3741
|
-
return true;
|
|
3742
|
-
}
|
|
3743
|
-
if (line instanceof RidLine$1) {
|
|
3744
|
-
this.rids.push(line);
|
|
3745
|
-
return true;
|
|
3746
|
-
}
|
|
3747
|
-
if (line instanceof RtcpMuxLine$1) {
|
|
3748
|
-
this.rtcpMux = true;
|
|
3749
|
-
return true;
|
|
3750
|
-
}
|
|
3751
|
-
if (line instanceof SimulcastLine$1) {
|
|
3752
|
-
this.simulcast = line;
|
|
3753
|
-
return true;
|
|
3754
|
-
}
|
|
3755
|
-
if (line instanceof RtpMapLine$1 || line instanceof FmtpLine$1 || line instanceof RtcpFbLine$1) {
|
|
3756
|
-
var codec = this.codecs.get(line.payloadType);
|
|
3757
|
-
if (!codec) {
|
|
3758
|
-
throw new Error("Error: got line for unknown codec: ".concat(line.toSdpLine()));
|
|
3759
|
-
}
|
|
3760
|
-
codec.addLine(line);
|
|
3761
|
-
return true;
|
|
3762
|
-
}
|
|
3763
|
-
if (line instanceof SsrcLine$1) {
|
|
3764
|
-
this.ssrcs.push(line);
|
|
3765
|
-
return true;
|
|
3766
|
-
}
|
|
3767
|
-
if (line instanceof SsrcGroupLine$1) {
|
|
3768
|
-
this.ssrcGroups.push(line);
|
|
3769
|
-
return true;
|
|
3770
|
-
}
|
|
3771
|
-
this.otherLines.push(line);
|
|
3772
|
-
return true;
|
|
3773
|
-
}
|
|
3774
|
-
getCodecByPt(pt) {
|
|
3775
|
-
return this.codecs.get(pt);
|
|
3776
|
-
}
|
|
3777
|
-
removePt(pt) {
|
|
3778
|
-
var associatedPts = [...this.codecs.values()].filter(ci => ci.primaryCodecPt === pt).map(ci => ci.pt);
|
|
3779
|
-
var allPtsToRemove = [pt, ...associatedPts];
|
|
3780
|
-
allPtsToRemove.forEach(ptToRemove => {
|
|
3781
|
-
this.codecs.delete(ptToRemove);
|
|
3782
|
-
});
|
|
3783
|
-
this.pts = this.pts.filter(existingPt => allPtsToRemove.indexOf(existingPt) === -1);
|
|
3784
|
-
}
|
|
3785
|
-
}
|
|
3786
|
-
class SessionDescription$1 {
|
|
3787
|
-
constructor() {
|
|
3788
|
-
this.groups = [];
|
|
3789
|
-
this.otherLines = [];
|
|
3790
|
-
}
|
|
3791
|
-
addLine(line) {
|
|
3792
|
-
if (line instanceof VersionLine$1) {
|
|
3793
|
-
this.version = line;
|
|
3794
|
-
return true;
|
|
3795
|
-
}
|
|
3796
|
-
if (line instanceof OriginLine$1) {
|
|
3797
|
-
this.origin = line;
|
|
3798
|
-
return true;
|
|
3799
|
-
}
|
|
3800
|
-
if (line instanceof SessionNameLine$1) {
|
|
3801
|
-
this.sessionName = line;
|
|
3802
|
-
return true;
|
|
3803
|
-
}
|
|
3804
|
-
if (line instanceof SessionInformationLine$1) {
|
|
3805
|
-
this.information = line;
|
|
3806
|
-
return true;
|
|
3807
|
-
}
|
|
3808
|
-
if (line instanceof TimingLine$1) {
|
|
3809
|
-
this.timing = line;
|
|
3810
|
-
return true;
|
|
3811
|
-
}
|
|
3812
|
-
if (line instanceof ConnectionLine$1) {
|
|
3813
|
-
this.connection = line;
|
|
3814
|
-
return true;
|
|
3815
|
-
}
|
|
3816
|
-
if (line instanceof BandwidthLine$1) {
|
|
3817
|
-
this.bandwidth = line;
|
|
3818
|
-
return true;
|
|
3819
|
-
}
|
|
3820
|
-
if (line instanceof BundleGroupLine$1) {
|
|
3821
|
-
this.groups.push(line);
|
|
3822
|
-
return true;
|
|
3823
|
-
}
|
|
3824
|
-
this.otherLines.push(line);
|
|
3825
|
-
return true;
|
|
3826
|
-
}
|
|
3827
|
-
toLines() {
|
|
3828
|
-
var lines = [];
|
|
3829
|
-
if (this.version) {
|
|
3830
|
-
lines.push(this.version);
|
|
3831
|
-
}
|
|
3832
|
-
if (this.origin) {
|
|
3833
|
-
lines.push(this.origin);
|
|
3834
|
-
}
|
|
3835
|
-
if (this.sessionName) {
|
|
3836
|
-
lines.push(this.sessionName);
|
|
3837
|
-
}
|
|
3838
|
-
if (this.information) {
|
|
3839
|
-
lines.push(this.information);
|
|
3840
|
-
}
|
|
3841
|
-
if (this.connection) {
|
|
3842
|
-
lines.push(this.connection);
|
|
3843
|
-
}
|
|
3844
|
-
if (this.bandwidth) {
|
|
3845
|
-
lines.push(this.bandwidth);
|
|
3846
|
-
}
|
|
3847
|
-
if (this.timing) {
|
|
3848
|
-
lines.push(this.timing);
|
|
3849
|
-
}
|
|
3850
|
-
if (this.groups) {
|
|
3851
|
-
lines.push(...this.groups);
|
|
3852
|
-
}
|
|
3853
|
-
lines.push(...this.otherLines);
|
|
3854
|
-
return lines;
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
class Sdp$1 {
|
|
3858
|
-
constructor() {
|
|
3859
|
-
this.session = new SessionDescription$1();
|
|
3860
|
-
this.media = [];
|
|
3861
|
-
}
|
|
3862
|
-
get avMedia() {
|
|
3863
|
-
return this.media.filter(mi => mi instanceof AvMediaDescription$1);
|
|
3864
|
-
}
|
|
3865
|
-
toString() {
|
|
3866
|
-
var lines = [];
|
|
3867
|
-
lines.push(...this.session.toLines());
|
|
3868
|
-
this.media.forEach(m => lines.push(...m.toLines()));
|
|
3869
|
-
return "".concat(lines.map(l => l.toSdpLine()).join('\r\n'), "\r\n");
|
|
3870
|
-
}
|
|
3871
|
-
}
|
|
3872
|
-
class Grammar$1 {
|
|
3873
|
-
constructor() {
|
|
3874
|
-
this.parsers = new Map();
|
|
3875
|
-
}
|
|
3876
|
-
addParser(lineType, parser) {
|
|
3877
|
-
var parsers = this.parsers.get(lineType) || [];
|
|
3878
|
-
parsers.push(parser);
|
|
3879
|
-
this.parsers.set(lineType, parsers);
|
|
3880
|
-
}
|
|
3881
|
-
getParsers(lineType) {
|
|
3882
|
-
return this.parsers.get(lineType) || [];
|
|
3883
|
-
}
|
|
3884
|
-
}
|
|
3885
|
-
class SdpGrammar$1 extends Grammar$1 {
|
|
3886
|
-
constructor() {
|
|
3887
|
-
super();
|
|
3888
|
-
this.addParser('v', VersionLine$1.fromSdpLine);
|
|
3889
|
-
this.addParser('o', OriginLine$1.fromSdpLine);
|
|
3890
|
-
this.addParser('c', ConnectionLine$1.fromSdpLine);
|
|
3891
|
-
this.addParser('i', SessionInformationLine$1.fromSdpLine);
|
|
3892
|
-
this.addParser('m', MediaLine$1.fromSdpLine);
|
|
3893
|
-
this.addParser('s', SessionNameLine$1.fromSdpLine);
|
|
3894
|
-
this.addParser('t', TimingLine$1.fromSdpLine);
|
|
3895
|
-
this.addParser('b', BandwidthLine$1.fromSdpLine);
|
|
3896
|
-
this.addParser('a', RtpMapLine$1.fromSdpLine);
|
|
3897
|
-
this.addParser('a', RtcpFbLine$1.fromSdpLine);
|
|
3898
|
-
this.addParser('a', FmtpLine$1.fromSdpLine);
|
|
3899
|
-
this.addParser('a', DirectionLine$1.fromSdpLine);
|
|
3900
|
-
this.addParser('a', ExtMapLine$1.fromSdpLine);
|
|
3901
|
-
this.addParser('a', MidLine$1.fromSdpLine);
|
|
3902
|
-
this.addParser('a', IceUfragLine$1.fromSdpLine);
|
|
3903
|
-
this.addParser('a', IcePwdLine$1.fromSdpLine);
|
|
3904
|
-
this.addParser('a', IceOptionsLine$1.fromSdpLine);
|
|
3905
|
-
this.addParser('a', FingerprintLine$1.fromSdpLine);
|
|
3906
|
-
this.addParser('a', SetupLine$1.fromSdpLine);
|
|
3907
|
-
this.addParser('a', SctpPortLine$1.fromSdpLine);
|
|
3908
|
-
this.addParser('a', MaxMessageSizeLine$1.fromSdpLine);
|
|
3909
|
-
this.addParser('a', RtcpMuxLine$1.fromSdpLine);
|
|
3910
|
-
this.addParser('a', BundleGroupLine$1.fromSdpLine);
|
|
3911
|
-
this.addParser('a', ContentLine$1.fromSdpLine);
|
|
3912
|
-
this.addParser('a', RidLine$1.fromSdpLine);
|
|
3913
|
-
this.addParser('a', CandidateLine$1.fromSdpLine);
|
|
3914
|
-
this.addParser('a', SimulcastLine$1.fromSdpLine);
|
|
3915
|
-
this.addParser('a', SsrcLine$1.fromSdpLine);
|
|
3916
|
-
this.addParser('a', SsrcGroupLine$1.fromSdpLine);
|
|
3917
|
-
}
|
|
3918
|
-
}
|
|
3919
|
-
var DefaultSdpGrammar$1 = new SdpGrammar$1();
|
|
3920
|
-
function isValidLine$1(line) {
|
|
3921
|
-
return line.length > 2;
|
|
3922
|
-
}
|
|
3923
|
-
function parseToModel$1(lines) {
|
|
3924
|
-
var sdp = new Sdp$1();
|
|
3925
|
-
var currBlock = sdp.session;
|
|
3926
|
-
lines.forEach(l => {
|
|
3927
|
-
if (l instanceof MediaLine$1) {
|
|
3928
|
-
var mediaInfo;
|
|
3929
|
-
if (l.type === 'audio' || l.type === 'video') {
|
|
3930
|
-
mediaInfo = new AvMediaDescription$1(l);
|
|
3931
|
-
} else if (l.type === 'application') {
|
|
3932
|
-
mediaInfo = new ApplicationMediaDescription$1(l);
|
|
3933
|
-
} else {
|
|
3934
|
-
throw new Error("Unhandled media type: ".concat(l.type));
|
|
3935
|
-
}
|
|
3936
|
-
sdp.media.push(mediaInfo);
|
|
3937
|
-
currBlock = mediaInfo;
|
|
3938
|
-
} else {
|
|
3939
|
-
currBlock.addLine(l);
|
|
3940
|
-
}
|
|
3941
|
-
});
|
|
3942
|
-
return sdp;
|
|
3943
|
-
}
|
|
3944
|
-
function parseToLines$1(sdp, grammar) {
|
|
3945
|
-
var lines = [];
|
|
3946
|
-
sdp.split(/(\r\n|\r|\n)/).filter(isValidLine$1).forEach(l => {
|
|
3947
|
-
var lineType = l[0];
|
|
3948
|
-
var lineValue = l.slice(2);
|
|
3949
|
-
var parsers = grammar.getParsers(lineType);
|
|
3950
|
-
for (var parser of parsers) {
|
|
3951
|
-
var _result = parser(lineValue);
|
|
3952
|
-
if (_result) {
|
|
3953
|
-
lines.push(_result);
|
|
3954
|
-
return;
|
|
3955
|
-
}
|
|
3956
|
-
}
|
|
3957
|
-
var result = UnknownLine$1.fromSdpLine(l);
|
|
3958
|
-
lines.push(result);
|
|
3959
|
-
});
|
|
3960
|
-
return lines;
|
|
3961
|
-
}
|
|
3962
|
-
function parse$2(sdp) {
|
|
3963
|
-
var grammar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DefaultSdpGrammar$1;
|
|
3964
|
-
var lines = parseToLines$1(sdp, grammar);
|
|
3965
|
-
var parsed = parseToModel$1(lines);
|
|
3966
|
-
return parsed;
|
|
3967
|
-
}
|
|
3968
|
-
|
|
3969
|
-
function getLocalTrackInfo(kind, receive, localTrack) {
|
|
3970
|
-
var direction = (() => {
|
|
3971
|
-
var send = !!localTrack;
|
|
3972
|
-
if (send && receive) return 'sendrecv';
|
|
3973
|
-
if (send && !receive) return 'sendonly';
|
|
3974
|
-
if (!send && receive) return 'recvonly';
|
|
3975
|
-
return 'inactive';
|
|
3976
|
-
})();
|
|
3977
|
-
return {
|
|
3978
|
-
trackOrKind: localTrack || kind,
|
|
3979
|
-
direction
|
|
3980
|
-
};
|
|
3981
|
-
}
|
|
3982
|
-
function hasH264Codec(mediaLine) {
|
|
3983
|
-
for (var codec of mediaLine.codecs.values()) {
|
|
3984
|
-
var _codec$name;
|
|
3985
|
-
if (((_codec$name = codec.name) === null || _codec$name === void 0 ? void 0 : _codec$name.toUpperCase()) === 'H264') {
|
|
3986
|
-
return true;
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
return false;
|
|
3990
|
-
}
|
|
3991
|
-
function checkSdpForErrors(options, sdp) {
|
|
3992
|
-
if (!sdp) {
|
|
3993
|
-
return new Error('SDP is missing');
|
|
3994
|
-
}
|
|
3995
|
-
var parsedSdp = parse$2(sdp);
|
|
3996
|
-
for (var mediaLine of parsedSdp.avMedia) {
|
|
3997
|
-
if (!mediaLine.iceInfo.candidates.length) {
|
|
3998
|
-
return new IceGatheringError("ice candidates missing for m-line with mid=".concat(mediaLine.mid));
|
|
3999
|
-
}
|
|
4000
|
-
if (!options.allowPort0 && mediaLine.port === 0) {
|
|
4001
|
-
return new SdpError("Found invalid port number 0 at m-line with mid=".concat(mediaLine.mid));
|
|
4002
|
-
}
|
|
4003
|
-
if (!mediaLine.iceInfo.pwd || !mediaLine.iceInfo.ufrag) {
|
|
4004
|
-
return new IceGatheringError("ice ufrag and password not found for m-line with mid=".concat(mediaLine.mid));
|
|
4005
|
-
}
|
|
4006
|
-
if (options.requireH264 && mediaLine.type === 'video' && !hasH264Codec(mediaLine)) {
|
|
4007
|
-
return new SdpError("H264 codec is missing for video media description with mid=".concat(mediaLine.mid));
|
|
4008
|
-
}
|
|
4009
|
-
}
|
|
4010
|
-
return false;
|
|
4011
|
-
}
|
|
4012
|
-
function convertCLineToIPv4(sdp) {
|
|
4013
|
-
var convertConnectionProp = connection => {
|
|
4014
|
-
if ((connection === null || connection === void 0 ? void 0 : connection.addrType) === 'IP6') {
|
|
4015
|
-
connection.addrType = 'IP4';
|
|
4016
|
-
connection.ipAddr = '0.0.0.0';
|
|
4017
|
-
}
|
|
4018
|
-
};
|
|
4019
|
-
convertConnectionProp(sdp.session.connection);
|
|
4020
|
-
sdp.media.forEach(media => {
|
|
4021
|
-
convertConnectionProp(media.connection);
|
|
4022
|
-
});
|
|
4023
|
-
}
|
|
4024
|
-
function convertPort9to0(sdp) {
|
|
4025
|
-
sdp.media.forEach(media => {
|
|
4026
|
-
if (media.port === 9) {
|
|
4027
|
-
media.port = 0;
|
|
4028
|
-
}
|
|
4029
|
-
});
|
|
4030
|
-
}
|
|
4031
|
-
function setContentSlides(sdp) {
|
|
4032
|
-
var videoMediaDescriptions = sdp.avMedia.filter(media => media.type === 'video');
|
|
4033
|
-
if (videoMediaDescriptions.length === 2) {
|
|
4034
|
-
videoMediaDescriptions[1].addLine(new ContentLine$1(['slides']));
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
|
-
class AnyLine extends Line$1 {
|
|
4038
|
-
constructor(value) {
|
|
4039
|
-
super();
|
|
4040
|
-
_defineProperty__default["default"](this, "value", void 0);
|
|
4041
|
-
this.value = value;
|
|
4042
|
-
}
|
|
4043
|
-
static fromSdpLine() {
|
|
4044
|
-
return undefined;
|
|
4045
|
-
}
|
|
4046
|
-
toSdpLine() {
|
|
4047
|
-
return "a=".concat(this.value);
|
|
4048
|
-
}
|
|
4049
|
-
}
|
|
4050
|
-
function addBandwidthLimits(sdp, limits) {
|
|
4051
|
-
sdp.avMedia.forEach(media => {
|
|
4052
|
-
if (media.type === 'audio') {
|
|
4053
|
-
media.addLine(new BandwidthLine$1('TIAS', limits.audio));
|
|
4054
|
-
} else if (media.type === 'video') {
|
|
4055
|
-
media.addLine(new BandwidthLine$1('TIAS', limits.video));
|
|
4056
|
-
}
|
|
4057
|
-
});
|
|
4058
|
-
}
|
|
4059
|
-
function addPeriodicKeyframes(sdp, value) {
|
|
4060
|
-
sdp.avMedia.forEach(media => {
|
|
4061
|
-
if (media.type === 'video') {
|
|
4062
|
-
media.addLine(new AnyLine("periodic-keyframes:".concat(value)));
|
|
4063
|
-
}
|
|
4064
|
-
});
|
|
4065
|
-
}
|
|
4066
|
-
function disableExtmap(sdp) {
|
|
4067
|
-
sdp.avMedia.forEach(media => {
|
|
4068
|
-
media.extMaps.length = 0;
|
|
4069
|
-
});
|
|
4070
|
-
}
|
|
4071
|
-
function updateH264fmtpParams(sdp, paramsToUpdate) {
|
|
4072
|
-
sdp.avMedia.forEach(media => {
|
|
4073
|
-
if (media.type === 'video') {
|
|
4074
|
-
media.codecs.forEach(codec => {
|
|
4075
|
-
var _codec$name2;
|
|
4076
|
-
if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
|
|
4077
|
-
paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
|
|
4078
|
-
}
|
|
4079
|
-
});
|
|
4080
|
-
}
|
|
4081
|
-
});
|
|
4082
|
-
}
|
|
4083
|
-
function adjustH264Profile(sdp, maxFsValue) {
|
|
4084
|
-
var maxFsForProfileLevel = {
|
|
4085
|
-
10: 99,
|
|
4086
|
-
11: 396,
|
|
4087
|
-
12: 396,
|
|
4088
|
-
13: 396,
|
|
4089
|
-
20: 396,
|
|
4090
|
-
21: 792,
|
|
4091
|
-
22: 1620,
|
|
4092
|
-
30: 1620,
|
|
4093
|
-
31: 3600,
|
|
4094
|
-
32: 5120,
|
|
4095
|
-
40: 8192,
|
|
4096
|
-
41: 8192,
|
|
4097
|
-
42: 8704,
|
|
4098
|
-
50: 22080,
|
|
4099
|
-
51: 36864,
|
|
4100
|
-
52: 36864,
|
|
4101
|
-
60: 139264,
|
|
4102
|
-
61: 139264,
|
|
4103
|
-
62: 139264
|
|
4104
|
-
};
|
|
4105
|
-
var framesPerSecond = 30;
|
|
4106
|
-
sdp.avMedia.forEach(media => {
|
|
4107
|
-
if (media.type === 'video') {
|
|
4108
|
-
media.codecs.forEach(codec => {
|
|
4109
|
-
var _codec$name3;
|
|
4110
|
-
if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
|
|
4111
|
-
var profileLevelIdValue = codec.fmtParams.get('profile-level-id');
|
|
4112
|
-
if (profileLevelIdValue) {
|
|
4113
|
-
var profile = profileLevelIdValue.substring(0, 4).toLowerCase();
|
|
4114
|
-
var levelId = parseInt(profileLevelIdValue.substring(4, 6), 16);
|
|
4115
|
-
if (!maxFsForProfileLevel[levelId]) {
|
|
4116
|
-
throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
|
|
4117
|
-
}
|
|
4118
|
-
if (maxFsForProfileLevel[levelId] === maxFsValue) {
|
|
4119
|
-
return;
|
|
4120
|
-
}
|
|
4121
|
-
if (maxFsForProfileLevel[levelId] < maxFsValue) {
|
|
4122
|
-
codec.fmtParams.set('max-fs', "".concat(maxFsValue));
|
|
4123
|
-
codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
|
|
4124
|
-
return;
|
|
4125
|
-
}
|
|
4126
|
-
var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
|
|
4127
|
-
if (newLevelId) {
|
|
4128
|
-
var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
|
|
4129
|
-
codec.fmtParams.set('profile-level-id', "".concat(profile).concat(newLevelIdHex));
|
|
4130
|
-
codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
|
|
4131
|
-
return;
|
|
4132
|
-
}
|
|
4133
|
-
throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
|
|
4134
|
-
}
|
|
4135
|
-
}
|
|
4136
|
-
});
|
|
4137
|
-
}
|
|
4138
|
-
});
|
|
4139
|
-
}
|
|
4140
|
-
function disableRtx(sdp) {
|
|
4141
|
-
sdp.avMedia.forEach(media => {
|
|
4142
|
-
var payloadTypesToRemove = [];
|
|
4143
|
-
media.codecs.forEach((codec, codecPt) => {
|
|
4144
|
-
if (codec.name === 'rtx' && codec.primaryCodecPt) {
|
|
4145
|
-
payloadTypesToRemove.push(codecPt);
|
|
4146
|
-
}
|
|
4147
|
-
});
|
|
4148
|
-
payloadTypesToRemove.forEach(pt => media.codecs.delete(pt));
|
|
4149
|
-
media.pts = media.pts.filter(pt => !payloadTypesToRemove.includes(pt));
|
|
4150
|
-
});
|
|
4151
|
-
}
|
|
4152
|
-
function mungeLocalSdpForBrowser(config, sdp) {
|
|
4153
|
-
var parsedSdp = parse$2(sdp);
|
|
4154
|
-
if (config.disableRtx) {
|
|
4155
|
-
disableRtx(parsedSdp);
|
|
4156
|
-
}
|
|
4157
|
-
return parsedSdp.toString();
|
|
4158
|
-
}
|
|
4159
|
-
function mungeLocalSdp(config, sdp) {
|
|
4160
|
-
var parsedSdp = parse$2(sdp);
|
|
4161
|
-
if (config.convertCLineToIPv4) {
|
|
4162
|
-
convertCLineToIPv4(parsedSdp);
|
|
4163
|
-
}
|
|
4164
|
-
if (config.bandwidthLimits) {
|
|
4165
|
-
addBandwidthLimits(parsedSdp, config.bandwidthLimits);
|
|
4166
|
-
}
|
|
4167
|
-
if (config.periodicKeyframes) {
|
|
4168
|
-
addPeriodicKeyframes(parsedSdp, config.periodicKeyframes);
|
|
4169
|
-
}
|
|
4170
|
-
if (config.convertPort9to0) {
|
|
4171
|
-
convertPort9to0(parsedSdp);
|
|
4172
|
-
}
|
|
4173
|
-
if (config.addContentSlides) {
|
|
4174
|
-
setContentSlides(parsedSdp);
|
|
4175
|
-
}
|
|
4176
|
-
if (config.disableExtmap) {
|
|
4177
|
-
disableExtmap(parsedSdp);
|
|
4178
|
-
}
|
|
4179
|
-
if (config.h264MaxFs) {
|
|
4180
|
-
adjustH264Profile(parsedSdp, config.h264MaxFs);
|
|
4181
|
-
}
|
|
4182
|
-
return parsedSdp.toString();
|
|
4183
|
-
}
|
|
4184
|
-
function setStartBitrate(sdp, startBitrate) {
|
|
4185
|
-
updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
|
|
4186
|
-
}
|
|
4187
|
-
function removeXtlsIceCandidates(sdp) {
|
|
4188
|
-
sdp.media.forEach(media => {
|
|
4189
|
-
media.iceInfo.candidates = media.iceInfo.candidates.filter(candidate => candidate.transport.toLowerCase() !== 'xtls');
|
|
4190
|
-
});
|
|
4191
|
-
}
|
|
4192
|
-
function mungeRemoteSdp(config, sdp) {
|
|
4193
|
-
var parsedSdp = parse$2(sdp);
|
|
4194
|
-
if (config.startBitrate) {
|
|
4195
|
-
setStartBitrate(parsedSdp, config.startBitrate);
|
|
4196
|
-
}
|
|
4197
|
-
if (config.disableExtmap) {
|
|
4198
|
-
disableExtmap(parsedSdp);
|
|
4199
|
-
}
|
|
4200
|
-
removeXtlsIceCandidates(parsedSdp);
|
|
4201
|
-
return parsedSdp.toString();
|
|
4202
|
-
}
|
|
4203
|
-
|
|
4204
2694
|
function _mergeNamespaces$1(n,m){m.forEach(function(e){e&&typeof e!=='string'&&!Array.isArray(e)&&Object.keys(e).forEach(function(k){if(k!=='default'&&!(k in n)){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function get(){return e[k];}});}});});return Object.freeze(n);}/******************************************************************************
|
|
4205
2695
|
Copyright (c) Microsoft Corporation.
|
|
4206
2696
|
|
|
@@ -5296,7 +3786,7 @@ Object.keys(updatedStats).forEach(function(id){var report=updatedStats[id];if(re
|
|
|
5296
3786
|
* @param name - Name of the event to log.
|
|
5297
3787
|
* @param payload - Log data pertaining to the event.
|
|
5298
3788
|
*/var trace=function trace(name,payload,timestamp){logger({id:id,timestamp:timestamp?Math.round(timestamp):Date.now(),name:name,payload:payload});};pc.addEventListener('icecandidate',function(e){if(e.candidate){trace('onicecandidate',makeEvent(JSON.stringify(e.candidate)));}});pc.addEventListener('icecandidateerror',function(event){var _a=event,errorCode=_a.errorCode,errorText=_a.errorText;trace('onicecandidateerror',makeEvent("".concat(errorCode,": ").concat(errorText)));});pc.addEventListener('track',function(e){trace('ontrack',makeEvent("".concat(e.track.kind,":").concat(e.track.id," ").concat(e.streams.map(function(stream){return "stream:".concat(stream.id);}).join(' '))));});pc.addEventListener('signalingstatechange',function(){trace('onsignalingstatechange',makeEvent(pc.signalingState));});pc.addEventListener('iceconnectionstatechange',function(){trace('oniceconnectionstatechange',makeEvent(pc.iceConnectionState));});pc.addEventListener('icegatheringstatechange',function(){trace('onicegatheringstatechange',makeEvent(pc.iceGatheringState));});pc.addEventListener('connectionstatechange',function(){trace('onconnectionstatechange',makeEvent(pc.connectionState));});pc.addEventListener('negotiationneeded',function(){trace('onnegotiationneeded',makeEvent('negotiationneeded'));});pc.addEventListener('datachannel',function(event){trace('ondatachannel',makeEvent("".concat(event.channel.id,": ").concat(event.channel.label)));});var interval=window.setInterval(function(){if(pc.signalingState==='closed'){window.clearInterval(interval);return;}pc.getStats(null).then(function(res){var now=map2obj(res);statsPreProcessor(now).then(function(){var base=deepCopy$1(now);// our new prev
|
|
5299
|
-
var compressed=deltaCompression(prev,now);trace('stats-report',formatStatsReport(compressed),compressed.timestamp!==-Infinity?compressed.timestamp:undefined);prev=base;});});},intervalTime);};rtcStats_1=rtcStats;var NUM='\\d+';var SDP_TOKEN="[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";var ANY_NON_WS='\\S+';var SP='\\s';var REST='.+';class Line{}var _a$5;class BandwidthLine extends Line{constructor(bandwidthType,bandwidth){super();this.bandwidthType=bandwidthType;this.bandwidth=bandwidth;}static fromSdpLine(line){if(!BandwidthLine.regex.test(line)){return undefined;}var tokens=line.match(BandwidthLine.regex);var bandwidthType=tokens[1];var bandwidth=parseInt(tokens[2],10);return new BandwidthLine(bandwidthType,bandwidth);}toSdpLine(){return "b=".concat(this.bandwidthType,":").concat(this.bandwidth);}}_a$5=BandwidthLine;BandwidthLine.BW_TYPE_REGEX='CT|AS|TIAS';BandwidthLine.regex=new RegExp("^(".concat(_a$5.BW_TYPE_REGEX,"):(").concat(NUM,")"));class BundleGroupLine extends Line{constructor(mids){super();this.mids=mids;}static fromSdpLine(line){if(!BundleGroupLine.regex.test(line)){return undefined;}var tokens=line.match(BundleGroupLine.regex);var mids=tokens[1].split(' ');return new BundleGroupLine(mids);}toSdpLine(){return "a=group:BUNDLE ".concat(this.mids.join(' '));}}BundleGroupLine.regex=new RegExp("^group:BUNDLE (".concat(REST,")"));var _a$4;class CandidateLine extends Line{constructor(foundation,componentId,transport,priority,connectionAddress,port,candidateType,relAddr,relPort,candidateExtensions){super();this.foundation=foundation;this.componentId=componentId;this.transport=transport;this.priority=priority;this.connectionAddress=connectionAddress;this.port=port;this.candidateType=candidateType;this.relAddr=relAddr;this.relPort=relPort;this.candidateExtensions=candidateExtensions;}static fromSdpLine(line){if(!CandidateLine.regex.test(line)){return undefined;}var tokens=line.match(CandidateLine.regex);var foundation=tokens[1];var componentId=parseInt(tokens[2],10);var transport=tokens[3];var priority=parseInt(tokens[4],10);var connectionAddress=tokens[5];var port=parseInt(tokens[6],10);var candidateType=tokens[7];var relAddr=tokens[8];var relPort=tokens[9]?parseInt(tokens[9],10):undefined;var candidateExtensions=tokens[10];return new CandidateLine(foundation,componentId,transport,priority,connectionAddress,port,candidateType,relAddr,relPort,candidateExtensions);}toSdpLine(){var str='';str+="a=candidate:".concat(this.foundation," ").concat(this.componentId," ").concat(this.transport," ").concat(this.priority," ").concat(this.connectionAddress," ").concat(this.port," typ ").concat(this.candidateType);if(this.relAddr){str+=" raddr ".concat(this.relAddr);}if(this.relPort){str+=" rport ".concat(this.relPort);}if(this.candidateExtensions){str+=" ".concat(this.candidateExtensions);}return str;}}_a$4=CandidateLine;CandidateLine.ICE_CHARS="[a-zA-Z0-9+/]+";CandidateLine.regex=new RegExp("^candidate:(".concat(_a$4.ICE_CHARS,") (").concat(NUM,") (").concat(ANY_NON_WS,") (").concat(NUM,") (").concat(ANY_NON_WS,") (").concat(NUM,") typ (").concat(ANY_NON_WS,")(?: raddr (").concat(ANY_NON_WS,"))?(?: rport (").concat(NUM,"))?(?: (").concat(REST,"))?"));class ConnectionLine extends Line{constructor(netType,addrType,ipAddr){super();this.netType=netType;this.addrType=addrType;this.ipAddr=ipAddr;}static fromSdpLine(line){if(!ConnectionLine.regex.test(line)){return undefined;}var tokens=line.match(ConnectionLine.regex);var netType=tokens[1];var addrType=tokens[2];var ipAddr=tokens[3];return new ConnectionLine(netType,addrType,ipAddr);}toSdpLine(){return "c=".concat(this.netType," ").concat(this.addrType," ").concat(this.ipAddr);}}ConnectionLine.regex=new RegExp("^(".concat(ANY_NON_WS,") (").concat(ANY_NON_WS,") (").concat(ANY_NON_WS,")"));class ContentLine extends Line{constructor(values){super();this.values=values;}static fromSdpLine(line){if(!ContentLine.regex.test(line)){return undefined;}var tokens=line.match(ContentLine.regex);var values=tokens[1].split(',');return new ContentLine(values);}toSdpLine(){return "a=content:".concat(this.values.join(','));}}ContentLine.regex=new RegExp("^content:(".concat(REST,")$"));class DirectionLine extends Line{constructor(direction){super();this.direction=direction;}static fromSdpLine(line){if(!DirectionLine.regex.test(line)){return undefined;}var tokens=line.match(DirectionLine.regex);var direction=tokens[1];return new DirectionLine(direction);}toSdpLine(){return "a=".concat(this.direction);}}DirectionLine.regex=/^(sendrecv|sendonly|recvonly|inactive)$/;var _a$3;class ExtMapLine extends Line{constructor(id,uri,direction,extensionAttributes){super();this.id=id;this.uri=uri;this.direction=direction;this.extensionAttributes=extensionAttributes;}static fromSdpLine(line){if(!ExtMapLine.regex.test(line)){return undefined;}var tokens=line.match(ExtMapLine.regex);var id=parseInt(tokens[1],10);var direction=tokens[2];var uri=tokens[3];var extensionAttributes=tokens[4];return new ExtMapLine(id,uri,direction,extensionAttributes);}toSdpLine(){var str='';str+="a=extmap:".concat(this.id);if(this.direction){str+="/".concat(this.direction);}str+=" ".concat(this.uri);if(this.extensionAttributes){str+=" ".concat(this.extensionAttributes);}return str;}}_a$3=ExtMapLine;ExtMapLine.EXTMAP_DIRECTION="sendonly|recvonly|sendrecv|inactive";ExtMapLine.regex=new RegExp("^extmap:(".concat(NUM,")(?:/(").concat(_a$3.EXTMAP_DIRECTION,"))? (").concat(ANY_NON_WS,")(?: (").concat(REST,"))?"));class FingerprintLine extends Line{constructor(fingerprint){super();this.fingerprint=fingerprint;}static fromSdpLine(line){if(!FingerprintLine.regex.test(line)){return undefined;}var tokens=line.match(FingerprintLine.regex);var fingerprint=tokens[1];return new FingerprintLine(fingerprint);}toSdpLine(){return "a=fingerprint:".concat(this.fingerprint);}}FingerprintLine.regex=new RegExp("^fingerprint:(".concat(REST,")"));function parseFmtpParams(fmtpParams){fmtpParams=fmtpParams.replace(/^a=fmtp:\d+\x20/,'');var fmtpObj=new Map();if(/^\d+([/-]\d+)+$/.test(fmtpParams)){fmtpObj.set(fmtpParams,undefined);return fmtpObj;}fmtpParams.split(';').forEach(param=>{var paramArr=param&¶m.split('=');if(paramArr.length!==2||!paramArr[0]||!paramArr[1]){throw new Error("Fmtp params is invalid with ".concat(fmtpParams));}fmtpObj.set(paramArr[0],paramArr[1]);});return fmtpObj;}class FmtpLine extends Line{constructor(payloadType,params){super();this.payloadType=payloadType;this.params=params;}static fromSdpLine(line){if(!FmtpLine.regex.test(line)){return undefined;}var tokens=line.match(FmtpLine.regex);var payloadType=parseInt(tokens[1],10);var params=tokens[2];return new FmtpLine(payloadType,parseFmtpParams(params));}toSdpLine(){var fmtParams=Array.from(this.params.keys()).map(key=>{if(this.params.get(key)!==undefined){return "".concat(key,"=").concat(this.params.get(key));}return "".concat(key);}).join(';');return "a=fmtp:".concat(this.payloadType," ").concat(fmtParams);}}FmtpLine.regex=new RegExp("^fmtp:(".concat(NUM,") (").concat(REST,")"));class IceOptionsLine extends Line{constructor(options){super();this.options=options;}static fromSdpLine(line){if(!IceOptionsLine.regex.test(line)){return undefined;}var tokens=line.match(IceOptionsLine.regex);var options=tokens[1].split(' ');return new IceOptionsLine(options);}toSdpLine(){return "a=ice-options:".concat(this.options.join(' '));}}IceOptionsLine.regex=new RegExp("^ice-options:(".concat(REST,")$"));class IcePwdLine extends Line{constructor(pwd){super();this.pwd=pwd;}static fromSdpLine(line){if(!IcePwdLine.regex.test(line)){return undefined;}var tokens=line.match(IcePwdLine.regex);var pwd=tokens[1];return new IcePwdLine(pwd);}toSdpLine(){return "a=ice-pwd:".concat(this.pwd);}}IcePwdLine.regex=new RegExp("^ice-pwd:(".concat(ANY_NON_WS,")$"));class IceUfragLine extends Line{constructor(ufrag){super();this.ufrag=ufrag;}static fromSdpLine(line){if(!IceUfragLine.regex.test(line)){return undefined;}var tokens=line.match(IceUfragLine.regex);var ufrag=tokens[1];return new IceUfragLine(ufrag);}toSdpLine(){return "a=ice-ufrag:".concat(this.ufrag);}}IceUfragLine.regex=new RegExp("^ice-ufrag:(".concat(ANY_NON_WS,")$"));class MaxMessageSizeLine extends Line{constructor(maxMessageSize){super();this.maxMessageSize=maxMessageSize;}static fromSdpLine(line){if(!MaxMessageSizeLine.regex.test(line)){return undefined;}var tokens=line.match(MaxMessageSizeLine.regex);var maxMessageSize=parseInt(tokens[1],10);return new MaxMessageSizeLine(maxMessageSize);}toSdpLine(){return "a=max-message-size:".concat(this.maxMessageSize);}}MaxMessageSizeLine.regex=new RegExp("^max-message-size:(".concat(NUM,")"));var _a$2;class MediaLine extends Line{constructor(type,port,protocol,formats){super();this.type=type;this.port=port;this.protocol=protocol;this.formats=formats;}static fromSdpLine(line){if(!MediaLine.regex.test(line)){return undefined;}var tokens=line.match(MediaLine.regex);var type=tokens[1];var port=parseInt(tokens[2],10);var protocol=tokens[3];var formats=tokens[4].split(' ');return new MediaLine(type,port,protocol,formats);}toSdpLine(){return "m=".concat(this.type," ").concat(this.port," ").concat(this.protocol," ").concat(this.formats.join(' '));}}_a$2=MediaLine;MediaLine.MEDIA_TYPE='audio|video|application';MediaLine.regex=new RegExp("^(".concat(_a$2.MEDIA_TYPE,") (").concat(NUM,") (").concat(ANY_NON_WS,") (").concat(REST,")"));class MidLine extends Line{constructor(mid){super();this.mid=mid;}static fromSdpLine(line){if(!MidLine.regex.test(line)){return undefined;}var tokens=line.match(MidLine.regex);var mid=tokens[1];return new MidLine(mid);}toSdpLine(){return "a=mid:".concat(this.mid);}}MidLine.regex=new RegExp("^mid:(".concat(ANY_NON_WS,")$"));class OriginLine extends Line{constructor(username,sessionId,sessionVersion,netType,addrType,ipAddr){super();this.username=username;this.sessionId=sessionId;this.sessionVersion=sessionVersion;this.netType=netType;this.addrType=addrType;this.ipAddr=ipAddr;}static fromSdpLine(line){if(!OriginLine.regex.test(line)){return undefined;}var tokens=line.match(OriginLine.regex);var username=tokens[1];var sessionId=tokens[2];var sessionVersion=parseInt(tokens[3],10);var netType=tokens[4];var addrType=tokens[5];var ipAddr=tokens[6];return new OriginLine(username,sessionId,sessionVersion,netType,addrType,ipAddr);}toSdpLine(){return "o=".concat(this.username," ").concat(this.sessionId," ").concat(this.sessionVersion," ").concat(this.netType," ").concat(this.addrType," ").concat(this.ipAddr);}}OriginLine.regex=new RegExp("^(".concat(ANY_NON_WS,") (").concat(ANY_NON_WS,") (").concat(NUM,") (").concat(ANY_NON_WS,") (").concat(ANY_NON_WS,") (").concat(ANY_NON_WS,")"));var _a$1;class RidLine extends Line{constructor(id,direction,params){super();this.id=id;this.direction=direction;this.params=params;}static fromSdpLine(line){if(!RidLine.regex.test(line)){return undefined;}var tokens=line.match(RidLine.regex);var id=tokens[1];var direction=tokens[2];var params=tokens[3];return new RidLine(id,direction,params);}toSdpLine(){var str='';str+="a=rid:".concat(this.id," ").concat(this.direction);if(this.params){str+=" ".concat(this.params);}return str;}}_a$1=RidLine;RidLine.RID_ID="[\\w-]+";RidLine.RID_DIRECTION="\\bsend\\b|\\brecv\\b";RidLine.regex=new RegExp("^rid:(".concat(_a$1.RID_ID,") (").concat(_a$1.RID_DIRECTION,")(?:").concat(SP,"(").concat(REST,"))?"));class RtcpMuxLine extends Line{static fromSdpLine(line){if(!RtcpMuxLine.regex.test(line)){return undefined;}return new RtcpMuxLine();}toSdpLine(){return "a=rtcp-mux";}}RtcpMuxLine.regex=/^rtcp-mux$/;class RtcpFbLine extends Line{constructor(payloadType,feedback){super();this.payloadType=payloadType;this.feedback=feedback;}static fromSdpLine(line){if(!RtcpFbLine.regex.test(line)){return undefined;}var tokens=line.match(RtcpFbLine.regex);var payloadType=parseInt(tokens[1],10);var feedback=tokens[2];return new RtcpFbLine(payloadType,feedback);}toSdpLine(){return "a=rtcp-fb:".concat(this.payloadType," ").concat(this.feedback);}}RtcpFbLine.regex=new RegExp("^rtcp-fb:(".concat(NUM,") (").concat(REST,")"));var _a$6;class RtpMapLine extends Line{constructor(payloadType,encodingName,clockRate,encodingParams){super();this.payloadType=payloadType;this.encodingName=encodingName;this.clockRate=clockRate;this.encodingParams=encodingParams;}static fromSdpLine(line){if(!RtpMapLine.regex.test(line)){return undefined;}var tokens=line.match(RtpMapLine.regex);var payloadType=parseInt(tokens[1],10);var encodingName=tokens[2];var clockRate=parseInt(tokens[3],10);var encodingParams=tokens[4];return new RtpMapLine(payloadType,encodingName,clockRate,encodingParams);}toSdpLine(){var str='';str+="a=rtpmap:".concat(this.payloadType," ").concat(this.encodingName,"/").concat(this.clockRate);if(this.encodingParams){str+="/".concat(this.encodingParams);}return str;}}_a$6=RtpMapLine;RtpMapLine.NON_SLASH_TOKEN='[^\\s/]+';RtpMapLine.regex=new RegExp("^rtpmap:(".concat(NUM,") (").concat(_a$6.NON_SLASH_TOKEN,")/(").concat(_a$6.NON_SLASH_TOKEN,")(?:/(").concat(_a$6.NON_SLASH_TOKEN,"))?"));class SctpPortLine extends Line{constructor(port){super();this.port=port;}static fromSdpLine(line){if(!SctpPortLine.regex.test(line)){return undefined;}var tokens=line.match(SctpPortLine.regex);var port=parseInt(tokens[1],10);return new SctpPortLine(port);}toSdpLine(){return "a=sctp-port:".concat(this.port);}}SctpPortLine.regex=new RegExp("^sctp-port:(".concat(NUM,")"));class SessionInformationLine extends Line{constructor(info){super();this.info=info;}static fromSdpLine(line){if(!SessionInformationLine.regex.test(line)){return undefined;}var tokens=line.match(SessionInformationLine.regex);var info=tokens[1];return new SessionInformationLine(info);}toSdpLine(){return "i=".concat(this.info);}}SessionInformationLine.regex=new RegExp("(".concat(REST,")"));class SessionNameLine extends Line{constructor(name){super();this.name=name;}static fromSdpLine(line){if(!SessionNameLine.regex.test(line)){return undefined;}var tokens=line.match(SessionNameLine.regex);var name=tokens[1];return new SessionNameLine(name);}toSdpLine(){return "s=".concat(this.name);}}SessionNameLine.regex=new RegExp("^(".concat(REST,")"));class SetupLine extends Line{constructor(setup){super();this.setup=setup;}static fromSdpLine(line){if(!SetupLine.regex.test(line)){return undefined;}var tokens=line.match(SetupLine.regex);var setup=tokens[1];return new SetupLine(setup);}toSdpLine(){return "a=setup:".concat(this.setup);}}SetupLine.regex=/^setup:(actpass|active|passive)$/;class SimulcastLayer{constructor(id,paused){this.id=id;this.paused=paused;}toString(){return this.paused?"~".concat(this.id):this.id;}}class SimulcastLayerList{constructor(){this.layers=[];}addLayer(layer){this.layers.push([layer]);}addLayerWithAlternatives(alternatives){this.layers.push(alternatives);}get length(){return this.layers.length;}get(index){return this.layers[index];}static fromString(str){var layerList=new SimulcastLayerList();var tokens=str.split(';');if(tokens.length===1&&!tokens[0].trim()){throw new Error('simulcast stream list empty');}tokens.forEach(token=>{if(!token){throw new Error('simulcast layer list empty');}var ridTokens=token.split(',');var layers=[];ridTokens.forEach(ridToken=>{if(!ridToken||ridToken==='~'){throw new Error('rid empty');}var paused=ridToken[0]==='~';var rid=paused?ridToken.substring(1):ridToken;layers.push(new SimulcastLayer(rid,paused));});layerList.addLayerWithAlternatives(layers);});return layerList;}toString(){return this.layers.map(altArray=>altArray.map(v=>v.toString()).join(',')).join(';');}}class SimulcastLine extends Line{constructor(sendLayers,recvLayers){super();this.sendLayers=sendLayers;this.recvLayers=recvLayers;}static fromSdpLine(line){if(!SimulcastLine.regex.test(line)){return undefined;}var tokens=line.match(SimulcastLine.regex);var bidirectional=tokens[3]&&tokens[4];var firstDirection=tokens[1];var layerList1=SimulcastLayerList.fromString(tokens[2]);var layerList2=new SimulcastLayerList();if(bidirectional){var secondDirection=tokens[3];if(firstDirection===secondDirection){return undefined;}layerList2=SimulcastLayerList.fromString(tokens[4]);}var sendLayerList;var recvLayerList;if(firstDirection==='send'){sendLayerList=layerList1;recvLayerList=layerList2;}else {sendLayerList=layerList2;recvLayerList=layerList1;}return new SimulcastLine(sendLayerList,recvLayerList);}toSdpLine(){var str='a=simulcast:';if(this.sendLayers.length){str+="send ".concat(this.sendLayers.toString());if(this.recvLayers.length){str+=" ";}}if(this.recvLayers.length){str+="recv ".concat(this.recvLayers.toString());}return str;}}SimulcastLine.regex=new RegExp("^simulcast:(send|recv) (".concat(ANY_NON_WS,")(?: (send|recv) (").concat(ANY_NON_WS,"))?"));class SsrcLine extends Line{constructor(ssrcId,attribute){var attributeValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:undefined;var attributeData=arguments.length>3&&arguments[3]!==undefined?arguments[3]:undefined;super();this.ssrcId=ssrcId;this.attribute=attribute;this.attributeValue=attributeValue;this.attributeData=attributeData;}static fromSdpLine(line){if(!SsrcLine.regex.test(line)){return undefined;}var tokens=line.match(SsrcLine.regex);var ssrcId=parseInt(tokens[1],10);var attribute=tokens[2];var attributeValue=tokens[3];var attributeData=tokens[4];return new SsrcLine(ssrcId,attribute,attributeValue,attributeData);}toSdpLine(){var str="a=ssrc:".concat(this.ssrcId," ").concat(this.attribute);if(this.attributeValue){str+=":".concat(this.attributeValue);}if(this.attributeData){str+=" ".concat(this.attributeData);}return str;}}SsrcLine.regex=new RegExp("^ssrc:(".concat(NUM,") (").concat(SDP_TOKEN,")(?::(").concat(SDP_TOKEN,")?(?: (").concat(ANY_NON_WS,"))?)?$"));class SsrcGroupLine extends Line{constructor(semantics,ssrcs){super();this.semantics=semantics;this.ssrcs=ssrcs;}static fromSdpLine(line){if(!SsrcGroupLine.regex.test(line)){return undefined;}var tokens=line.match(SsrcGroupLine.regex);var semantics=tokens[1];var ssrcs=tokens[2].split(' ').map(ssrcStr=>parseInt(ssrcStr,10));return new SsrcGroupLine(semantics,ssrcs);}toSdpLine(){return "a=ssrc-group:".concat(this.semantics," ").concat(this.ssrcs.join(' '));}}SsrcGroupLine.regex=new RegExp("^ssrc-group:(SIM|FID|FEC) ((?:".concat(NUM).concat(SP,"*)+)"));class TimingLine extends Line{constructor(startTime,stopTime){super();this.startTime=startTime;this.stopTime=stopTime;}static fromSdpLine(line){if(!TimingLine.regex.test(line)){return undefined;}var tokens=line.match(TimingLine.regex);var startTime=parseInt(tokens[1],10);var stopTime=parseInt(tokens[2],10);return new TimingLine(startTime,stopTime);}toSdpLine(){return "t=".concat(this.startTime," ").concat(this.stopTime);}}TimingLine.regex=new RegExp("^(".concat(NUM,") (").concat(NUM,")"));class VersionLine extends Line{constructor(version){super();this.version=version;}static fromSdpLine(line){if(!VersionLine.regex.test(line)){return undefined;}var tokens=line.match(VersionLine.regex);var version=parseInt(tokens[1],10);return new VersionLine(version);}toSdpLine(){return "v=".concat(this.version);}}VersionLine.regex=new RegExp("^(".concat(NUM,")$"));class UnknownLine extends Line{constructor(value){super();this.value=value;}static fromSdpLine(line){var tokens=line.match(UnknownLine.regex);var value=tokens[1];return new UnknownLine(value);}toSdpLine(){return "".concat(this.value);}}UnknownLine.regex=new RegExp("(".concat(REST,")"));class IceInfo{constructor(){this.candidates=[];}addLine(line){if(line instanceof IceUfragLine){this.ufrag=line;return true;}if(line instanceof IcePwdLine){this.pwd=line;return true;}if(line instanceof IceOptionsLine){this.options=line;return true;}if(line instanceof CandidateLine){this.candidates.push(line);return true;}return false;}toLines(){var lines=[];if(this.ufrag){lines.push(this.ufrag);}if(this.pwd){lines.push(this.pwd);}if(this.options){lines.push(this.options);}this.candidates.forEach(candidate=>lines.push(candidate));return lines;}}class MediaDescription{constructor(type,port,protocol){this.iceInfo=new IceInfo();this.otherLines=[];this.type=type;this.port=port;this.protocol=protocol;}findOtherLine(ty){return this.otherLines.find(line=>line instanceof ty);}addLine(line){if(line instanceof BundleGroupLine){throw new Error("Error: bundle group line not allowed in media description");}if(line instanceof BandwidthLine){this.bandwidth=line;return true;}if(line instanceof MidLine){this.mid=line.mid;return true;}if(line instanceof FingerprintLine){this.fingerprint=line.fingerprint;return true;}if(line instanceof SetupLine){this.setup=line.setup;return true;}if(line instanceof ConnectionLine){this.connection=line;return true;}if(line instanceof ContentLine){this.content=line;return true;}return this.iceInfo.addLine(line);}}class ApplicationMediaDescription extends MediaDescription{constructor(mediaLine){super(mediaLine.type,mediaLine.port,mediaLine.protocol);this.fmts=[];this.fmts=mediaLine.formats;}toLines(){var lines=[];lines.push(new MediaLine(this.type,this.port,this.protocol,this.fmts));if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}lines.push(...this.iceInfo.toLines());if(this.fingerprint){lines.push(new FingerprintLine(this.fingerprint));}if(this.setup){lines.push(new SetupLine(this.setup));}if(this.mid){lines.push(new MidLine(this.mid));}if(this.content){lines.push(this.content);}if(this.sctpPort){lines.push(new SctpPortLine(this.sctpPort));}if(this.maxMessageSize){lines.push(new MaxMessageSizeLine(this.maxMessageSize));}lines.push(...this.otherLines);return lines;}addLine(line){if(super.addLine(line)){return true;}if(line instanceof MediaLine){throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');}if(line instanceof SctpPortLine){this.sctpPort=line.port;return true;}if(line instanceof MaxMessageSizeLine){this.maxMessageSize=line.maxMessageSize;return true;}this.otherLines.push(line);return true;}}class CodecInfo$1{constructor(pt){this.fmtParams=new Map();this.feedback=[];this.pt=pt;}addLine(line){if(line instanceof RtpMapLine){this.name=line.encodingName;this.clockRate=line.clockRate;this.encodingParams=line.encodingParams;return true;}if(line instanceof FmtpLine){this.fmtParams=new Map([...Array.from(this.fmtParams.entries()),...Array.from(line.params.entries())]);if(line.params.has('apt')){var apt=line.params.get('apt');this.primaryCodecPt=parseInt(apt,10);}return true;}if(line instanceof RtcpFbLine){this.feedback.push(line.feedback);return true;}return false;}toLines(){var lines=[];lines.push(new RtpMapLine(this.pt,this.name,this.clockRate,this.encodingParams));this.feedback.forEach(fb=>{lines.push(new RtcpFbLine(this.pt,fb));});if(this.fmtParams.size>0){lines.push(new FmtpLine(this.pt,this.fmtParams));}return lines;}}class AvMediaDescription extends MediaDescription{constructor(mediaLine){super(mediaLine.type,mediaLine.port,mediaLine.protocol);this.pts=[];this.extMaps=[];this.rids=[];this.codecs=new Map();this.rtcpMux=false;this.ssrcs=[];this.ssrcGroups=[];this.pts=mediaLine.formats.map(fmt=>{return parseInt(fmt,10);});this.pts.forEach(pt=>this.codecs.set(pt,new CodecInfo$1(pt)));}toLines(){var lines=[];lines.push(new MediaLine(this.type,this.port,this.protocol,this.pts.map(pt=>"".concat(pt))));if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}lines.push(...this.iceInfo.toLines());if(this.fingerprint){lines.push(new FingerprintLine(this.fingerprint));}if(this.setup){lines.push(new SetupLine(this.setup));}if(this.mid){lines.push(new MidLine(this.mid));}if(this.rtcpMux){lines.push(new RtcpMuxLine());}if(this.content){lines.push(this.content);}this.extMaps.forEach(extMap=>lines.push(extMap));this.rids.forEach(rid=>lines.push(rid));if(this.simulcast){lines.push(this.simulcast);}if(this.direction){lines.push(new DirectionLine(this.direction));}this.codecs.forEach(codec=>lines.push(...codec.toLines()));lines.push(...this.ssrcs);lines.push(...this.ssrcGroups);lines.push(...this.otherLines);return lines;}addLine(line){if(super.addLine(line)){return true;}if(line instanceof MediaLine){throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');}if(line instanceof DirectionLine){this.direction=line.direction;return true;}if(line instanceof ExtMapLine){this.extMaps.push(line);return true;}if(line instanceof RidLine){this.rids.push(line);return true;}if(line instanceof RtcpMuxLine){this.rtcpMux=true;return true;}if(line instanceof SimulcastLine){this.simulcast=line;return true;}if(line instanceof RtpMapLine||line instanceof FmtpLine||line instanceof RtcpFbLine){var codec=this.codecs.get(line.payloadType);if(!codec){throw new Error("Error: got line for unknown codec: ".concat(line.toSdpLine()));}codec.addLine(line);return true;}if(line instanceof SsrcLine){this.ssrcs.push(line);return true;}if(line instanceof SsrcGroupLine){this.ssrcGroups.push(line);return true;}this.otherLines.push(line);return true;}getCodecByPt(pt){return this.codecs.get(pt);}removePt(pt){var associatedPts=[...this.codecs.values()].filter(ci=>ci.primaryCodecPt===pt).map(ci=>ci.pt);var allPtsToRemove=[pt,...associatedPts];allPtsToRemove.forEach(ptToRemove=>{this.codecs.delete(ptToRemove);});this.pts=this.pts.filter(existingPt=>allPtsToRemove.indexOf(existingPt)===-1);}}class SessionDescription{constructor(){this.groups=[];this.otherLines=[];}addLine(line){if(line instanceof VersionLine){this.version=line;return true;}if(line instanceof OriginLine){this.origin=line;return true;}if(line instanceof SessionNameLine){this.sessionName=line;return true;}if(line instanceof SessionInformationLine){this.information=line;return true;}if(line instanceof TimingLine){this.timing=line;return true;}if(line instanceof ConnectionLine){this.connection=line;return true;}if(line instanceof BandwidthLine){this.bandwidth=line;return true;}if(line instanceof BundleGroupLine){this.groups.push(line);return true;}this.otherLines.push(line);return true;}toLines(){var lines=[];if(this.version){lines.push(this.version);}if(this.origin){lines.push(this.origin);}if(this.sessionName){lines.push(this.sessionName);}if(this.information){lines.push(this.information);}if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}if(this.timing){lines.push(this.timing);}if(this.groups){lines.push(...this.groups);}lines.push(...this.otherLines);return lines;}}class Sdp{constructor(){this.session=new SessionDescription();this.media=[];}get avMedia(){return this.media.filter(mi=>mi instanceof AvMediaDescription);}toString(){var lines=[];lines.push(...this.session.toLines());this.media.forEach(m=>lines.push(...m.toLines()));return "".concat(lines.map(l=>l.toSdpLine()).join('\r\n'),"\r\n");}}class Grammar{constructor(){this.parsers=new Map();}addParser(lineType,parser){var parsers=this.parsers.get(lineType)||[];parsers.push(parser);this.parsers.set(lineType,parsers);}getParsers(lineType){return this.parsers.get(lineType)||[];}}class SdpGrammar extends Grammar{constructor(){super();this.addParser('v',VersionLine.fromSdpLine);this.addParser('o',OriginLine.fromSdpLine);this.addParser('c',ConnectionLine.fromSdpLine);this.addParser('i',SessionInformationLine.fromSdpLine);this.addParser('m',MediaLine.fromSdpLine);this.addParser('s',SessionNameLine.fromSdpLine);this.addParser('t',TimingLine.fromSdpLine);this.addParser('b',BandwidthLine.fromSdpLine);this.addParser('a',RtpMapLine.fromSdpLine);this.addParser('a',RtcpFbLine.fromSdpLine);this.addParser('a',FmtpLine.fromSdpLine);this.addParser('a',DirectionLine.fromSdpLine);this.addParser('a',ExtMapLine.fromSdpLine);this.addParser('a',MidLine.fromSdpLine);this.addParser('a',IceUfragLine.fromSdpLine);this.addParser('a',IcePwdLine.fromSdpLine);this.addParser('a',IceOptionsLine.fromSdpLine);this.addParser('a',FingerprintLine.fromSdpLine);this.addParser('a',SetupLine.fromSdpLine);this.addParser('a',SctpPortLine.fromSdpLine);this.addParser('a',MaxMessageSizeLine.fromSdpLine);this.addParser('a',RtcpMuxLine.fromSdpLine);this.addParser('a',BundleGroupLine.fromSdpLine);this.addParser('a',ContentLine.fromSdpLine);this.addParser('a',RidLine.fromSdpLine);this.addParser('a',CandidateLine.fromSdpLine);this.addParser('a',SimulcastLine.fromSdpLine);this.addParser('a',SsrcLine.fromSdpLine);this.addParser('a',SsrcGroupLine.fromSdpLine);}}var DefaultSdpGrammar=new SdpGrammar();function isValidLine(line){return line.length>2;}function parseToModel(lines){var sdp=new Sdp();var currBlock=sdp.session;lines.forEach(l=>{if(l instanceof MediaLine){var mediaInfo;if(l.type==='audio'||l.type==='video'){mediaInfo=new AvMediaDescription(l);}else if(l.type==='application'){mediaInfo=new ApplicationMediaDescription(l);}else {throw new Error("Unhandled media type: ".concat(l.type));}sdp.media.push(mediaInfo);currBlock=mediaInfo;}else {currBlock.addLine(l);}});return sdp;}function parseToLines(sdp,grammar){var lines=[];sdp.split(/(\r\n|\r|\n)/).filter(isValidLine).forEach(l=>{var lineType=l[0];var lineValue=l.slice(2);var parsers=grammar.getParsers(lineType);for(var parser of parsers){var _result=parser(lineValue);if(_result){lines.push(_result);return;}}var result=UnknownLine.fromSdpLine(l);lines.push(result);});return lines;}function parse(sdp){var grammar=arguments.length>1&&arguments[1]!==undefined?arguments[1]:DefaultSdpGrammar;var lines=parseToLines(sdp,grammar);var parsed=parseToModel(lines);return parsed;}function removeCodec(sdp,codecName){sdp.avMedia.forEach(media=>{var codecInfos=[...media.codecs.entries()].filter(_ref=>{var[,ci]=_ref;var _a;return ((_a=ci.name)===null||_a===void 0?void 0:_a.toLowerCase())===codecName.toLowerCase();});codecInfos.forEach(_ref2=>{var[pt]=_ref2;return media.removePt(pt);});});}function hasCodec(codecName,mLine){return [...mLine.codecs.values()].some(ci=>{var _a;return ((_a=ci.name)===null||_a===void 0?void 0:_a.toLowerCase())===codecName.toLowerCase();});}var events={exports:{}};var R=typeof Reflect==='object'?Reflect:null;var ReflectApply=R&&typeof R.apply==='function'?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args);};var ReflectOwnKeys;if(R&&typeof R.ownKeys==='function'){ReflectOwnKeys=R.ownKeys;}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));};}else {ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target);};}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning);}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value;};function EventEmitter$1(){EventEmitter$1.init.call(this);}events.exports=EventEmitter$1;events.exports.once=once$1;// Backwards-compat with node 0.10.x
|
|
3789
|
+
var compressed=deltaCompression(prev,now);trace('stats-report',formatStatsReport(compressed),compressed.timestamp!==-Infinity?compressed.timestamp:undefined);prev=base;});});},intervalTime);};rtcStats_1=rtcStats;var NUM$1='\\d+';var SDP_TOKEN$1="[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";var ANY_NON_WS$1='\\S+';var SP$1='\\s';var REST$1='.+';class Line$1{}var _a$5$1;class BandwidthLine$1 extends Line$1{constructor(bandwidthType,bandwidth){super();this.bandwidthType=bandwidthType;this.bandwidth=bandwidth;}static fromSdpLine(line){if(!BandwidthLine$1.regex.test(line)){return undefined;}var tokens=line.match(BandwidthLine$1.regex);var bandwidthType=tokens[1];var bandwidth=parseInt(tokens[2],10);return new BandwidthLine$1(bandwidthType,bandwidth);}toSdpLine(){return "b=".concat(this.bandwidthType,":").concat(this.bandwidth);}}_a$5$1=BandwidthLine$1;BandwidthLine$1.BW_TYPE_REGEX='CT|AS|TIAS';BandwidthLine$1.regex=new RegExp("^(".concat(_a$5$1.BW_TYPE_REGEX,"):(").concat(NUM$1,")"));class BundleGroupLine$1 extends Line$1{constructor(mids){super();this.mids=mids;}static fromSdpLine(line){if(!BundleGroupLine$1.regex.test(line)){return undefined;}var tokens=line.match(BundleGroupLine$1.regex);var mids=tokens[1].split(' ');return new BundleGroupLine$1(mids);}toSdpLine(){return "a=group:BUNDLE ".concat(this.mids.join(' '));}}BundleGroupLine$1.regex=new RegExp("^group:BUNDLE (".concat(REST$1,")"));var _a$4$1;class CandidateLine$1 extends Line$1{constructor(foundation,componentId,transport,priority,connectionAddress,port,candidateType,relAddr,relPort,candidateExtensions){super();this.foundation=foundation;this.componentId=componentId;this.transport=transport;this.priority=priority;this.connectionAddress=connectionAddress;this.port=port;this.candidateType=candidateType;this.relAddr=relAddr;this.relPort=relPort;this.candidateExtensions=candidateExtensions;}static fromSdpLine(line){if(!CandidateLine$1.regex.test(line)){return undefined;}var tokens=line.match(CandidateLine$1.regex);var foundation=tokens[1];var componentId=parseInt(tokens[2],10);var transport=tokens[3];var priority=parseInt(tokens[4],10);var connectionAddress=tokens[5];var port=parseInt(tokens[6],10);var candidateType=tokens[7];var relAddr=tokens[8];var relPort=tokens[9]?parseInt(tokens[9],10):undefined;var candidateExtensions=tokens[10];return new CandidateLine$1(foundation,componentId,transport,priority,connectionAddress,port,candidateType,relAddr,relPort,candidateExtensions);}toSdpLine(){var str='';str+="a=candidate:".concat(this.foundation," ").concat(this.componentId," ").concat(this.transport," ").concat(this.priority," ").concat(this.connectionAddress," ").concat(this.port," typ ").concat(this.candidateType);if(this.relAddr){str+=" raddr ".concat(this.relAddr);}if(this.relPort){str+=" rport ".concat(this.relPort);}if(this.candidateExtensions){str+=" ".concat(this.candidateExtensions);}return str;}}_a$4$1=CandidateLine$1;CandidateLine$1.ICE_CHARS="[a-zA-Z0-9+/]+";CandidateLine$1.regex=new RegExp("^candidate:(".concat(_a$4$1.ICE_CHARS,") (").concat(NUM$1,") (").concat(ANY_NON_WS$1,") (").concat(NUM$1,") (").concat(ANY_NON_WS$1,") (").concat(NUM$1,") typ (").concat(ANY_NON_WS$1,")(?: raddr (").concat(ANY_NON_WS$1,"))?(?: rport (").concat(NUM$1,"))?(?: (").concat(REST$1,"))?"));class ConnectionLine$1 extends Line$1{constructor(netType,addrType,ipAddr){super();this.netType=netType;this.addrType=addrType;this.ipAddr=ipAddr;}static fromSdpLine(line){if(!ConnectionLine$1.regex.test(line)){return undefined;}var tokens=line.match(ConnectionLine$1.regex);var netType=tokens[1];var addrType=tokens[2];var ipAddr=tokens[3];return new ConnectionLine$1(netType,addrType,ipAddr);}toSdpLine(){return "c=".concat(this.netType," ").concat(this.addrType," ").concat(this.ipAddr);}}ConnectionLine$1.regex=new RegExp("^(".concat(ANY_NON_WS$1,") (").concat(ANY_NON_WS$1,") (").concat(ANY_NON_WS$1,")"));class ContentLine$1 extends Line$1{constructor(values){super();this.values=values;}static fromSdpLine(line){if(!ContentLine$1.regex.test(line)){return undefined;}var tokens=line.match(ContentLine$1.regex);var values=tokens[1].split(',');return new ContentLine$1(values);}toSdpLine(){return "a=content:".concat(this.values.join(','));}}ContentLine$1.regex=new RegExp("^content:(".concat(REST$1,")$"));class DirectionLine$1 extends Line$1{constructor(direction){super();this.direction=direction;}static fromSdpLine(line){if(!DirectionLine$1.regex.test(line)){return undefined;}var tokens=line.match(DirectionLine$1.regex);var direction=tokens[1];return new DirectionLine$1(direction);}toSdpLine(){return "a=".concat(this.direction);}}DirectionLine$1.regex=/^(sendrecv|sendonly|recvonly|inactive)$/;var _a$3$1;class ExtMapLine$1 extends Line$1{constructor(id,uri,direction,extensionAttributes){super();this.id=id;this.uri=uri;this.direction=direction;this.extensionAttributes=extensionAttributes;}static fromSdpLine(line){if(!ExtMapLine$1.regex.test(line)){return undefined;}var tokens=line.match(ExtMapLine$1.regex);var id=parseInt(tokens[1],10);var direction=tokens[2];var uri=tokens[3];var extensionAttributes=tokens[4];return new ExtMapLine$1(id,uri,direction,extensionAttributes);}toSdpLine(){var str='';str+="a=extmap:".concat(this.id);if(this.direction){str+="/".concat(this.direction);}str+=" ".concat(this.uri);if(this.extensionAttributes){str+=" ".concat(this.extensionAttributes);}return str;}}_a$3$1=ExtMapLine$1;ExtMapLine$1.EXTMAP_DIRECTION="sendonly|recvonly|sendrecv|inactive";ExtMapLine$1.regex=new RegExp("^extmap:(".concat(NUM$1,")(?:/(").concat(_a$3$1.EXTMAP_DIRECTION,"))? (").concat(ANY_NON_WS$1,")(?: (").concat(REST$1,"))?"));class FingerprintLine$1 extends Line$1{constructor(fingerprint){super();this.fingerprint=fingerprint;}static fromSdpLine(line){if(!FingerprintLine$1.regex.test(line)){return undefined;}var tokens=line.match(FingerprintLine$1.regex);var fingerprint=tokens[1];return new FingerprintLine$1(fingerprint);}toSdpLine(){return "a=fingerprint:".concat(this.fingerprint);}}FingerprintLine$1.regex=new RegExp("^fingerprint:(".concat(REST$1,")"));function parseFmtpParams$1(fmtpParams){fmtpParams=fmtpParams.replace(/^a=fmtp:\d+\x20/,'');var fmtpObj=new Map();if(/^\d+([/-]\d+)+$/.test(fmtpParams)){fmtpObj.set(fmtpParams,undefined);return fmtpObj;}fmtpParams.split(';').forEach(param=>{var paramArr=param&¶m.split('=');if(paramArr.length!==2||!paramArr[0]||!paramArr[1]){throw new Error("Fmtp params is invalid with ".concat(fmtpParams));}fmtpObj.set(paramArr[0],paramArr[1]);});return fmtpObj;}class FmtpLine$1 extends Line$1{constructor(payloadType,params){super();this.payloadType=payloadType;this.params=params;}static fromSdpLine(line){if(!FmtpLine$1.regex.test(line)){return undefined;}var tokens=line.match(FmtpLine$1.regex);var payloadType=parseInt(tokens[1],10);var params=tokens[2];return new FmtpLine$1(payloadType,parseFmtpParams$1(params));}toSdpLine(){var fmtParams=Array.from(this.params.keys()).map(key=>{if(this.params.get(key)!==undefined){return "".concat(key,"=").concat(this.params.get(key));}return "".concat(key);}).join(';');return "a=fmtp:".concat(this.payloadType," ").concat(fmtParams);}}FmtpLine$1.regex=new RegExp("^fmtp:(".concat(NUM$1,") (").concat(REST$1,")"));class IceOptionsLine$1 extends Line$1{constructor(options){super();this.options=options;}static fromSdpLine(line){if(!IceOptionsLine$1.regex.test(line)){return undefined;}var tokens=line.match(IceOptionsLine$1.regex);var options=tokens[1].split(' ');return new IceOptionsLine$1(options);}toSdpLine(){return "a=ice-options:".concat(this.options.join(' '));}}IceOptionsLine$1.regex=new RegExp("^ice-options:(".concat(REST$1,")$"));class IcePwdLine$1 extends Line$1{constructor(pwd){super();this.pwd=pwd;}static fromSdpLine(line){if(!IcePwdLine$1.regex.test(line)){return undefined;}var tokens=line.match(IcePwdLine$1.regex);var pwd=tokens[1];return new IcePwdLine$1(pwd);}toSdpLine(){return "a=ice-pwd:".concat(this.pwd);}}IcePwdLine$1.regex=new RegExp("^ice-pwd:(".concat(ANY_NON_WS$1,")$"));class IceUfragLine$1 extends Line$1{constructor(ufrag){super();this.ufrag=ufrag;}static fromSdpLine(line){if(!IceUfragLine$1.regex.test(line)){return undefined;}var tokens=line.match(IceUfragLine$1.regex);var ufrag=tokens[1];return new IceUfragLine$1(ufrag);}toSdpLine(){return "a=ice-ufrag:".concat(this.ufrag);}}IceUfragLine$1.regex=new RegExp("^ice-ufrag:(".concat(ANY_NON_WS$1,")$"));class MaxMessageSizeLine$1 extends Line$1{constructor(maxMessageSize){super();this.maxMessageSize=maxMessageSize;}static fromSdpLine(line){if(!MaxMessageSizeLine$1.regex.test(line)){return undefined;}var tokens=line.match(MaxMessageSizeLine$1.regex);var maxMessageSize=parseInt(tokens[1],10);return new MaxMessageSizeLine$1(maxMessageSize);}toSdpLine(){return "a=max-message-size:".concat(this.maxMessageSize);}}MaxMessageSizeLine$1.regex=new RegExp("^max-message-size:(".concat(NUM$1,")"));var _a$2$1;class MediaLine$1 extends Line$1{constructor(type,port,protocol,formats){super();this.type=type;this.port=port;this.protocol=protocol;this.formats=formats;}static fromSdpLine(line){if(!MediaLine$1.regex.test(line)){return undefined;}var tokens=line.match(MediaLine$1.regex);var type=tokens[1];var port=parseInt(tokens[2],10);var protocol=tokens[3];var formats=tokens[4].split(' ');return new MediaLine$1(type,port,protocol,formats);}toSdpLine(){return "m=".concat(this.type," ").concat(this.port," ").concat(this.protocol," ").concat(this.formats.join(' '));}}_a$2$1=MediaLine$1;MediaLine$1.MEDIA_TYPE='audio|video|application';MediaLine$1.regex=new RegExp("^(".concat(_a$2$1.MEDIA_TYPE,") (").concat(NUM$1,") (").concat(ANY_NON_WS$1,") (").concat(REST$1,")"));class MidLine$1 extends Line$1{constructor(mid){super();this.mid=mid;}static fromSdpLine(line){if(!MidLine$1.regex.test(line)){return undefined;}var tokens=line.match(MidLine$1.regex);var mid=tokens[1];return new MidLine$1(mid);}toSdpLine(){return "a=mid:".concat(this.mid);}}MidLine$1.regex=new RegExp("^mid:(".concat(ANY_NON_WS$1,")$"));class OriginLine$1 extends Line$1{constructor(username,sessionId,sessionVersion,netType,addrType,ipAddr){super();this.username=username;this.sessionId=sessionId;this.sessionVersion=sessionVersion;this.netType=netType;this.addrType=addrType;this.ipAddr=ipAddr;}static fromSdpLine(line){if(!OriginLine$1.regex.test(line)){return undefined;}var tokens=line.match(OriginLine$1.regex);var username=tokens[1];var sessionId=tokens[2];var sessionVersion=parseInt(tokens[3],10);var netType=tokens[4];var addrType=tokens[5];var ipAddr=tokens[6];return new OriginLine$1(username,sessionId,sessionVersion,netType,addrType,ipAddr);}toSdpLine(){return "o=".concat(this.username," ").concat(this.sessionId," ").concat(this.sessionVersion," ").concat(this.netType," ").concat(this.addrType," ").concat(this.ipAddr);}}OriginLine$1.regex=new RegExp("^(".concat(ANY_NON_WS$1,") (").concat(ANY_NON_WS$1,") (").concat(NUM$1,") (").concat(ANY_NON_WS$1,") (").concat(ANY_NON_WS$1,") (").concat(ANY_NON_WS$1,")"));var _a$1$1;class RidLine$1 extends Line$1{constructor(id,direction,params){super();this.id=id;this.direction=direction;this.params=params;}static fromSdpLine(line){if(!RidLine$1.regex.test(line)){return undefined;}var tokens=line.match(RidLine$1.regex);var id=tokens[1];var direction=tokens[2];var params=tokens[3];return new RidLine$1(id,direction,params);}toSdpLine(){var str='';str+="a=rid:".concat(this.id," ").concat(this.direction);if(this.params){str+=" ".concat(this.params);}return str;}}_a$1$1=RidLine$1;RidLine$1.RID_ID="[\\w-]+";RidLine$1.RID_DIRECTION="\\bsend\\b|\\brecv\\b";RidLine$1.regex=new RegExp("^rid:(".concat(_a$1$1.RID_ID,") (").concat(_a$1$1.RID_DIRECTION,")(?:").concat(SP$1,"(").concat(REST$1,"))?"));class RtcpMuxLine$1 extends Line$1{static fromSdpLine(line){if(!RtcpMuxLine$1.regex.test(line)){return undefined;}return new RtcpMuxLine$1();}toSdpLine(){return "a=rtcp-mux";}}RtcpMuxLine$1.regex=/^rtcp-mux$/;class RtcpFbLine$1 extends Line$1{constructor(payloadType,feedback){super();this.payloadType=payloadType;this.feedback=feedback;}static fromSdpLine(line){if(!RtcpFbLine$1.regex.test(line)){return undefined;}var tokens=line.match(RtcpFbLine$1.regex);var payloadType=parseInt(tokens[1],10);var feedback=tokens[2];return new RtcpFbLine$1(payloadType,feedback);}toSdpLine(){return "a=rtcp-fb:".concat(this.payloadType," ").concat(this.feedback);}}RtcpFbLine$1.regex=new RegExp("^rtcp-fb:(".concat(NUM$1,") (").concat(REST$1,")"));var _a$7;class RtpMapLine$1 extends Line$1{constructor(payloadType,encodingName,clockRate,encodingParams){super();this.payloadType=payloadType;this.encodingName=encodingName;this.clockRate=clockRate;this.encodingParams=encodingParams;}static fromSdpLine(line){if(!RtpMapLine$1.regex.test(line)){return undefined;}var tokens=line.match(RtpMapLine$1.regex);var payloadType=parseInt(tokens[1],10);var encodingName=tokens[2];var clockRate=parseInt(tokens[3],10);var encodingParams=tokens[4];return new RtpMapLine$1(payloadType,encodingName,clockRate,encodingParams);}toSdpLine(){var str='';str+="a=rtpmap:".concat(this.payloadType," ").concat(this.encodingName,"/").concat(this.clockRate);if(this.encodingParams){str+="/".concat(this.encodingParams);}return str;}}_a$7=RtpMapLine$1;RtpMapLine$1.NON_SLASH_TOKEN='[^\\s/]+';RtpMapLine$1.regex=new RegExp("^rtpmap:(".concat(NUM$1,") (").concat(_a$7.NON_SLASH_TOKEN,")/(").concat(_a$7.NON_SLASH_TOKEN,")(?:/(").concat(_a$7.NON_SLASH_TOKEN,"))?"));class SctpPortLine$1 extends Line$1{constructor(port){super();this.port=port;}static fromSdpLine(line){if(!SctpPortLine$1.regex.test(line)){return undefined;}var tokens=line.match(SctpPortLine$1.regex);var port=parseInt(tokens[1],10);return new SctpPortLine$1(port);}toSdpLine(){return "a=sctp-port:".concat(this.port);}}SctpPortLine$1.regex=new RegExp("^sctp-port:(".concat(NUM$1,")"));class SessionInformationLine$1 extends Line$1{constructor(info){super();this.info=info;}static fromSdpLine(line){if(!SessionInformationLine$1.regex.test(line)){return undefined;}var tokens=line.match(SessionInformationLine$1.regex);var info=tokens[1];return new SessionInformationLine$1(info);}toSdpLine(){return "i=".concat(this.info);}}SessionInformationLine$1.regex=new RegExp("(".concat(REST$1,")"));class SessionNameLine$1 extends Line$1{constructor(name){super();this.name=name;}static fromSdpLine(line){if(!SessionNameLine$1.regex.test(line)){return undefined;}var tokens=line.match(SessionNameLine$1.regex);var name=tokens[1];return new SessionNameLine$1(name);}toSdpLine(){return "s=".concat(this.name);}}SessionNameLine$1.regex=new RegExp("^(".concat(REST$1,")"));class SetupLine$1 extends Line$1{constructor(setup){super();this.setup=setup;}static fromSdpLine(line){if(!SetupLine$1.regex.test(line)){return undefined;}var tokens=line.match(SetupLine$1.regex);var setup=tokens[1];return new SetupLine$1(setup);}toSdpLine(){return "a=setup:".concat(this.setup);}}SetupLine$1.regex=/^setup:(actpass|active|passive)$/;class SimulcastLayer$1{constructor(id,paused){this.id=id;this.paused=paused;}toString(){return this.paused?"~".concat(this.id):this.id;}}class SimulcastLayerList$1{constructor(){this.layers=[];}addLayer(layer){this.layers.push([layer]);}addLayerWithAlternatives(alternatives){this.layers.push(alternatives);}get length(){return this.layers.length;}get(index){return this.layers[index];}static fromString(str){var layerList=new SimulcastLayerList$1();var tokens=str.split(';');if(tokens.length===1&&!tokens[0].trim()){throw new Error('simulcast stream list empty');}tokens.forEach(token=>{if(!token){throw new Error('simulcast layer list empty');}var ridTokens=token.split(',');var layers=[];ridTokens.forEach(ridToken=>{if(!ridToken||ridToken==='~'){throw new Error('rid empty');}var paused=ridToken[0]==='~';var rid=paused?ridToken.substring(1):ridToken;layers.push(new SimulcastLayer$1(rid,paused));});layerList.addLayerWithAlternatives(layers);});return layerList;}toString(){return this.layers.map(altArray=>altArray.map(v=>v.toString()).join(',')).join(';');}}class SimulcastLine$1 extends Line$1{constructor(sendLayers,recvLayers){super();this.sendLayers=sendLayers;this.recvLayers=recvLayers;}static fromSdpLine(line){if(!SimulcastLine$1.regex.test(line)){return undefined;}var tokens=line.match(SimulcastLine$1.regex);var bidirectional=tokens[3]&&tokens[4];var firstDirection=tokens[1];var layerList1=SimulcastLayerList$1.fromString(tokens[2]);var layerList2=new SimulcastLayerList$1();if(bidirectional){var secondDirection=tokens[3];if(firstDirection===secondDirection){return undefined;}layerList2=SimulcastLayerList$1.fromString(tokens[4]);}var sendLayerList;var recvLayerList;if(firstDirection==='send'){sendLayerList=layerList1;recvLayerList=layerList2;}else {sendLayerList=layerList2;recvLayerList=layerList1;}return new SimulcastLine$1(sendLayerList,recvLayerList);}toSdpLine(){var str='a=simulcast:';if(this.sendLayers.length){str+="send ".concat(this.sendLayers.toString());if(this.recvLayers.length){str+=" ";}}if(this.recvLayers.length){str+="recv ".concat(this.recvLayers.toString());}return str;}}SimulcastLine$1.regex=new RegExp("^simulcast:(send|recv) (".concat(ANY_NON_WS$1,")(?: (send|recv) (").concat(ANY_NON_WS$1,"))?"));class SsrcLine$1 extends Line$1{constructor(ssrcId,attribute){var attributeValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:undefined;var attributeData=arguments.length>3&&arguments[3]!==undefined?arguments[3]:undefined;super();this.ssrcId=ssrcId;this.attribute=attribute;this.attributeValue=attributeValue;this.attributeData=attributeData;}static fromSdpLine(line){if(!SsrcLine$1.regex.test(line)){return undefined;}var tokens=line.match(SsrcLine$1.regex);var ssrcId=parseInt(tokens[1],10);var attribute=tokens[2];var attributeValue=tokens[3];var attributeData=tokens[4];return new SsrcLine$1(ssrcId,attribute,attributeValue,attributeData);}toSdpLine(){var str="a=ssrc:".concat(this.ssrcId," ").concat(this.attribute);if(this.attributeValue){str+=":".concat(this.attributeValue);}if(this.attributeData){str+=" ".concat(this.attributeData);}return str;}}SsrcLine$1.regex=new RegExp("^ssrc:(".concat(NUM$1,") (").concat(SDP_TOKEN$1,")(?::(").concat(SDP_TOKEN$1,")?(?: (").concat(ANY_NON_WS$1,"))?)?$"));class SsrcGroupLine$1 extends Line$1{constructor(semantics,ssrcs){super();this.semantics=semantics;this.ssrcs=ssrcs;}static fromSdpLine(line){if(!SsrcGroupLine$1.regex.test(line)){return undefined;}var tokens=line.match(SsrcGroupLine$1.regex);var semantics=tokens[1];var ssrcs=tokens[2].split(' ').map(ssrcStr=>parseInt(ssrcStr,10));return new SsrcGroupLine$1(semantics,ssrcs);}toSdpLine(){return "a=ssrc-group:".concat(this.semantics," ").concat(this.ssrcs.join(' '));}}SsrcGroupLine$1.regex=new RegExp("^ssrc-group:(SIM|FID|FEC) ((?:".concat(NUM$1).concat(SP$1,"*)+)"));class TimingLine$1 extends Line$1{constructor(startTime,stopTime){super();this.startTime=startTime;this.stopTime=stopTime;}static fromSdpLine(line){if(!TimingLine$1.regex.test(line)){return undefined;}var tokens=line.match(TimingLine$1.regex);var startTime=parseInt(tokens[1],10);var stopTime=parseInt(tokens[2],10);return new TimingLine$1(startTime,stopTime);}toSdpLine(){return "t=".concat(this.startTime," ").concat(this.stopTime);}}TimingLine$1.regex=new RegExp("^(".concat(NUM$1,") (").concat(NUM$1,")"));class VersionLine$1 extends Line$1{constructor(version){super();this.version=version;}static fromSdpLine(line){if(!VersionLine$1.regex.test(line)){return undefined;}var tokens=line.match(VersionLine$1.regex);var version=parseInt(tokens[1],10);return new VersionLine$1(version);}toSdpLine(){return "v=".concat(this.version);}}VersionLine$1.regex=new RegExp("^(".concat(NUM$1,")$"));class UnknownLine$1 extends Line$1{constructor(value){super();this.value=value;}static fromSdpLine(line){var tokens=line.match(UnknownLine$1.regex);var value=tokens[1];return new UnknownLine$1(value);}toSdpLine(){return "".concat(this.value);}}UnknownLine$1.regex=new RegExp("(".concat(REST$1,")"));class IceInfo$1{constructor(){this.candidates=[];}addLine(line){if(line instanceof IceUfragLine$1){this.ufrag=line;return true;}if(line instanceof IcePwdLine$1){this.pwd=line;return true;}if(line instanceof IceOptionsLine$1){this.options=line;return true;}if(line instanceof CandidateLine$1){this.candidates.push(line);return true;}return false;}toLines(){var lines=[];if(this.ufrag){lines.push(this.ufrag);}if(this.pwd){lines.push(this.pwd);}if(this.options){lines.push(this.options);}this.candidates.forEach(candidate=>lines.push(candidate));return lines;}}class MediaDescription$1{constructor(type,port,protocol){this.iceInfo=new IceInfo$1();this.otherLines=[];this.type=type;this.port=port;this.protocol=protocol;}findOtherLine(ty){return this.otherLines.find(line=>line instanceof ty);}addLine(line){if(line instanceof BundleGroupLine$1){throw new Error("Error: bundle group line not allowed in media description");}if(line instanceof BandwidthLine$1){this.bandwidth=line;return true;}if(line instanceof MidLine$1){this.mid=line.mid;return true;}if(line instanceof FingerprintLine$1){this.fingerprint=line.fingerprint;return true;}if(line instanceof SetupLine$1){this.setup=line.setup;return true;}if(line instanceof ConnectionLine$1){this.connection=line;return true;}if(line instanceof ContentLine$1){this.content=line;return true;}return this.iceInfo.addLine(line);}}class ApplicationMediaDescription$1 extends MediaDescription$1{constructor(mediaLine){super(mediaLine.type,mediaLine.port,mediaLine.protocol);this.fmts=[];this.fmts=mediaLine.formats;}toLines(){var lines=[];lines.push(new MediaLine$1(this.type,this.port,this.protocol,this.fmts));if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}lines.push(...this.iceInfo.toLines());if(this.fingerprint){lines.push(new FingerprintLine$1(this.fingerprint));}if(this.setup){lines.push(new SetupLine$1(this.setup));}if(this.mid){lines.push(new MidLine$1(this.mid));}if(this.content){lines.push(this.content);}if(this.sctpPort){lines.push(new SctpPortLine$1(this.sctpPort));}if(this.maxMessageSize){lines.push(new MaxMessageSizeLine$1(this.maxMessageSize));}lines.push(...this.otherLines);return lines;}addLine(line){if(super.addLine(line)){return true;}if(line instanceof MediaLine$1){throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');}if(line instanceof SctpPortLine$1){this.sctpPort=line.port;return true;}if(line instanceof MaxMessageSizeLine$1){this.maxMessageSize=line.maxMessageSize;return true;}this.otherLines.push(line);return true;}}class CodecInfo$2{constructor(pt){this.fmtParams=new Map();this.feedback=[];this.pt=pt;}addLine(line){if(line instanceof RtpMapLine$1){this.name=line.encodingName;this.clockRate=line.clockRate;this.encodingParams=line.encodingParams;return true;}if(line instanceof FmtpLine$1){this.fmtParams=new Map([...Array.from(this.fmtParams.entries()),...Array.from(line.params.entries())]);if(line.params.has('apt')){var apt=line.params.get('apt');this.primaryCodecPt=parseInt(apt,10);}return true;}if(line instanceof RtcpFbLine$1){this.feedback.push(line.feedback);return true;}return false;}toLines(){var lines=[];lines.push(new RtpMapLine$1(this.pt,this.name,this.clockRate,this.encodingParams));this.feedback.forEach(fb=>{lines.push(new RtcpFbLine$1(this.pt,fb));});if(this.fmtParams.size>0){lines.push(new FmtpLine$1(this.pt,this.fmtParams));}return lines;}}class AvMediaDescription$1 extends MediaDescription$1{constructor(mediaLine){super(mediaLine.type,mediaLine.port,mediaLine.protocol);this.pts=[];this.extMaps=[];this.rids=[];this.codecs=new Map();this.rtcpMux=false;this.ssrcs=[];this.ssrcGroups=[];this.pts=mediaLine.formats.map(fmt=>{return parseInt(fmt,10);});this.pts.forEach(pt=>this.codecs.set(pt,new CodecInfo$2(pt)));}toLines(){var lines=[];lines.push(new MediaLine$1(this.type,this.port,this.protocol,this.pts.map(pt=>"".concat(pt))));if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}lines.push(...this.iceInfo.toLines());if(this.fingerprint){lines.push(new FingerprintLine$1(this.fingerprint));}if(this.setup){lines.push(new SetupLine$1(this.setup));}if(this.mid){lines.push(new MidLine$1(this.mid));}if(this.rtcpMux){lines.push(new RtcpMuxLine$1());}if(this.content){lines.push(this.content);}this.extMaps.forEach(extMap=>lines.push(extMap));this.rids.forEach(rid=>lines.push(rid));if(this.simulcast){lines.push(this.simulcast);}if(this.direction){lines.push(new DirectionLine$1(this.direction));}this.codecs.forEach(codec=>lines.push(...codec.toLines()));lines.push(...this.ssrcs);lines.push(...this.ssrcGroups);lines.push(...this.otherLines);return lines;}addLine(line){if(super.addLine(line)){return true;}if(line instanceof MediaLine$1){throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');}if(line instanceof DirectionLine$1){this.direction=line.direction;return true;}if(line instanceof ExtMapLine$1){this.extMaps.push(line);return true;}if(line instanceof RidLine$1){this.rids.push(line);return true;}if(line instanceof RtcpMuxLine$1){this.rtcpMux=true;return true;}if(line instanceof SimulcastLine$1){this.simulcast=line;return true;}if(line instanceof RtpMapLine$1||line instanceof FmtpLine$1||line instanceof RtcpFbLine$1){var codec=this.codecs.get(line.payloadType);if(!codec){throw new Error("Error: got line for unknown codec: ".concat(line.toSdpLine()));}codec.addLine(line);return true;}if(line instanceof SsrcLine$1){this.ssrcs.push(line);return true;}if(line instanceof SsrcGroupLine$1){this.ssrcGroups.push(line);return true;}this.otherLines.push(line);return true;}getCodecByPt(pt){return this.codecs.get(pt);}removePt(pt){var associatedPts=[...this.codecs.values()].filter(ci=>ci.primaryCodecPt===pt).map(ci=>ci.pt);var allPtsToRemove=[pt,...associatedPts];allPtsToRemove.forEach(ptToRemove=>{this.codecs.delete(ptToRemove);});this.pts=this.pts.filter(existingPt=>allPtsToRemove.indexOf(existingPt)===-1);}}class SessionDescription$1{constructor(){this.groups=[];this.otherLines=[];}addLine(line){if(line instanceof VersionLine$1){this.version=line;return true;}if(line instanceof OriginLine$1){this.origin=line;return true;}if(line instanceof SessionNameLine$1){this.sessionName=line;return true;}if(line instanceof SessionInformationLine$1){this.information=line;return true;}if(line instanceof TimingLine$1){this.timing=line;return true;}if(line instanceof ConnectionLine$1){this.connection=line;return true;}if(line instanceof BandwidthLine$1){this.bandwidth=line;return true;}if(line instanceof BundleGroupLine$1){this.groups.push(line);return true;}this.otherLines.push(line);return true;}toLines(){var lines=[];if(this.version){lines.push(this.version);}if(this.origin){lines.push(this.origin);}if(this.sessionName){lines.push(this.sessionName);}if(this.information){lines.push(this.information);}if(this.connection){lines.push(this.connection);}if(this.bandwidth){lines.push(this.bandwidth);}if(this.timing){lines.push(this.timing);}if(this.groups){lines.push(...this.groups);}lines.push(...this.otherLines);return lines;}}class Sdp$1{constructor(){this.session=new SessionDescription$1();this.media=[];}get avMedia(){return this.media.filter(mi=>mi instanceof AvMediaDescription$1);}toString(){var lines=[];lines.push(...this.session.toLines());this.media.forEach(m=>lines.push(...m.toLines()));return "".concat(lines.map(l=>l.toSdpLine()).join('\r\n'),"\r\n");}}class Grammar$1{constructor(){this.parsers=new Map();}addParser(lineType,parser){var parsers=this.parsers.get(lineType)||[];parsers.push(parser);this.parsers.set(lineType,parsers);}getParsers(lineType){return this.parsers.get(lineType)||[];}}class SdpGrammar$1 extends Grammar$1{constructor(){super();this.addParser('v',VersionLine$1.fromSdpLine);this.addParser('o',OriginLine$1.fromSdpLine);this.addParser('c',ConnectionLine$1.fromSdpLine);this.addParser('i',SessionInformationLine$1.fromSdpLine);this.addParser('m',MediaLine$1.fromSdpLine);this.addParser('s',SessionNameLine$1.fromSdpLine);this.addParser('t',TimingLine$1.fromSdpLine);this.addParser('b',BandwidthLine$1.fromSdpLine);this.addParser('a',RtpMapLine$1.fromSdpLine);this.addParser('a',RtcpFbLine$1.fromSdpLine);this.addParser('a',FmtpLine$1.fromSdpLine);this.addParser('a',DirectionLine$1.fromSdpLine);this.addParser('a',ExtMapLine$1.fromSdpLine);this.addParser('a',MidLine$1.fromSdpLine);this.addParser('a',IceUfragLine$1.fromSdpLine);this.addParser('a',IcePwdLine$1.fromSdpLine);this.addParser('a',IceOptionsLine$1.fromSdpLine);this.addParser('a',FingerprintLine$1.fromSdpLine);this.addParser('a',SetupLine$1.fromSdpLine);this.addParser('a',SctpPortLine$1.fromSdpLine);this.addParser('a',MaxMessageSizeLine$1.fromSdpLine);this.addParser('a',RtcpMuxLine$1.fromSdpLine);this.addParser('a',BundleGroupLine$1.fromSdpLine);this.addParser('a',ContentLine$1.fromSdpLine);this.addParser('a',RidLine$1.fromSdpLine);this.addParser('a',CandidateLine$1.fromSdpLine);this.addParser('a',SimulcastLine$1.fromSdpLine);this.addParser('a',SsrcLine$1.fromSdpLine);this.addParser('a',SsrcGroupLine$1.fromSdpLine);}}var DefaultSdpGrammar$1=new SdpGrammar$1();function isValidLine$1(line){return line.length>2;}function parseToModel$1(lines){var sdp=new Sdp$1();var currBlock=sdp.session;lines.forEach(l=>{if(l instanceof MediaLine$1){var mediaInfo;if(l.type==='audio'||l.type==='video'){mediaInfo=new AvMediaDescription$1(l);}else if(l.type==='application'){mediaInfo=new ApplicationMediaDescription$1(l);}else {throw new Error("Unhandled media type: ".concat(l.type));}sdp.media.push(mediaInfo);currBlock=mediaInfo;}else {currBlock.addLine(l);}});return sdp;}function parseToLines$1(sdp,grammar){var lines=[];sdp.split(/(\r\n|\r|\n)/).filter(isValidLine$1).forEach(l=>{var lineType=l[0];var lineValue=l.slice(2);var parsers=grammar.getParsers(lineType);for(var parser of parsers){var _result=parser(lineValue);if(_result){lines.push(_result);return;}}var result=UnknownLine$1.fromSdpLine(l);lines.push(result);});return lines;}function parse$2(sdp){var grammar=arguments.length>1&&arguments[1]!==undefined?arguments[1]:DefaultSdpGrammar$1;var lines=parseToLines$1(sdp,grammar);var parsed=parseToModel$1(lines);return parsed;}function removeCodec(sdp,codecName){sdp.avMedia.forEach(media=>{var codecInfos=[...media.codecs.entries()].filter(_ref=>{var[,ci]=_ref;var _a;return ((_a=ci.name)===null||_a===void 0?void 0:_a.toLowerCase())===codecName.toLowerCase();});codecInfos.forEach(_ref2=>{var[pt]=_ref2;return media.removePt(pt);});});}function hasCodec(codecName,mLine){return [...mLine.codecs.values()].some(ci=>{var _a;return ((_a=ci.name)===null||_a===void 0?void 0:_a.toLowerCase())===codecName.toLowerCase();});}var events={exports:{}};var R=typeof Reflect==='object'?Reflect:null;var ReflectApply=R&&typeof R.apply==='function'?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args);};var ReflectOwnKeys;if(R&&typeof R.ownKeys==='function'){ReflectOwnKeys=R.ownKeys;}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));};}else {ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target);};}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning);}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value;};function EventEmitter$1(){EventEmitter$1.init.call(this);}events.exports=EventEmitter$1;events.exports.once=once$1;// Backwards-compat with node 0.10.x
|
|
5300
3790
|
EventEmitter$1.EventEmitter=EventEmitter$1;EventEmitter$1.prototype._events=undefined;EventEmitter$1.prototype._eventsCount=0;EventEmitter$1.prototype._maxListeners=undefined;// By default EventEmitters will print a warning if more than 10 listeners are
|
|
5301
3791
|
// added to it. This is a useful default which helps finding memory leaks.
|
|
5302
3792
|
var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=='function'){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener);}}Object.defineProperty(EventEmitter$1,'defaultMaxListeners',{enumerable:true,get:function get(){return defaultMaxListeners;},set:function set(arg){if(typeof arg!=='number'||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+'.');}defaultMaxListeners=arg;}});EventEmitter$1.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0;}this._maxListeners=this._maxListeners||undefined;};// Obviously not all Emitters should be limited to 10. This function allows
|
|
@@ -5325,7 +3815,7 @@ for(i=listeners.length-1;i>=0;i--){this.removeListener(type,listeners[i]);}}retu
|
|
|
5325
3815
|
// EventEmitters, we do not listen for `error` events here.
|
|
5326
3816
|
emitter.addEventListener(name,function wrapListener(arg){// IE does not have builtin `{ once: true }` support so we
|
|
5327
3817
|
// have to do it manually.
|
|
5328
|
-
if(flags.once){emitter.removeEventListener(name,wrapListener);}listener(arg);});}else {throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof emitter);}}class EventEmitter extends events.exports.EventEmitter{}var OveruseState;(function(OveruseState){OveruseState[OveruseState["NOT_OVERUSED"]=0]="NOT_OVERUSED";OveruseState[OveruseState["OVERUSED"]=1]="OVERUSED";})(OveruseState||(OveruseState={}));class OveruseStateManager{constructor(callback){this.monitors=[];this.lastOverallOveruseState=OveruseState.NOT_OVERUSED;this.isRunning=false;this.overuseUpdateCallback=callback;}addMonitor(monitor){this.monitors.push(monitor);if(this.isRunning){monitor.startMonitoring(()=>this.onMonitorOveruseUpdate());}}start(){this.isRunning=true;this.monitors.forEach(monitor=>monitor.startMonitoring(()=>this.onMonitorOveruseUpdate()));}stop(){this.isRunning=false;this.monitors.forEach(monitor=>monitor.stopMonitoring());}onMonitorOveruseUpdate(){var overuseStates=this.monitors.map(monitor=>monitor.getLastOveruseState());var overallOveruseState=overuseStates.some(overuseState=>overuseState===OveruseState.OVERUSED)?OveruseState.OVERUSED:OveruseState.NOT_OVERUSED;if(overallOveruseState!==this.lastOverallOveruseState){this.lastOverallOveruseState=overallOveruseState;this.overuseUpdateCallback(overallOveruseState);}}}exports.ReceiveSlotEvents = void 0;(function(ReceiveSlotEvents){ReceiveSlotEvents["MediaStarted"]="media-started";ReceiveSlotEvents["MediaStopped"]="media-stopped";ReceiveSlotEvents["SourceUpdate"]="source-update";})(exports.ReceiveSlotEvents||(exports.ReceiveSlotEvents={}));class ReceiveSlot extends EventEmitter{constructor(idGetter,track){super();this._idGetter=idGetter;this.handleTrackMuted=this.handleTrackMuted.bind(this);this.handleTrackUnmuted=this.handleTrackUnmuted.bind(this);this._stream=new MediaStream([track]);this._sourceState='no source';this.addTrackHandlers(track);}addTrackHandlers(track){track.addEventListener('mute',this.handleTrackMuted);track.addEventListener('unmute',this.handleTrackUnmuted);}handleTrackMuted(){this.emit(exports.ReceiveSlotEvents.MediaStopped);}handleTrackUnmuted(){this.emit(exports.ReceiveSlotEvents.MediaStarted);}removeTrackHandlers(track){track.removeEventListener('mute',this.handleTrackMuted);track.removeEventListener('unmute',this.handleTrackUnmuted);}replaceTrack(newTrack){var _a;var trackToRemove=(_a=this._stream.getTracks())===null||_a===void 0?void 0:_a[0];if(trackToRemove){this._stream.removeTrack(trackToRemove);this.removeTrackHandlers(trackToRemove);}this.addTrackHandlers(newTrack);this._stream.addTrack(newTrack);}_updateSource(state,csi){if(state!==this._sourceState||csi!==this._currentRxCsi){this._sourceState=state;this._currentRxCsi=csi;this.emit(exports.ReceiveSlotEvents.SourceUpdate,state,csi);}}close(){this._stream.getTracks().forEach(t=>{this.removeTrackHandlers(t);});}get id(){return this._idGetter();}get stream(){return this._stream;}get currentRxCsi(){return this._currentRxCsi;}}ReceiveSlot.Events=exports.ReceiveSlotEvents;class Transceiver{constructor(rtcRtpTransceiver){this._rtcRtpTransceiver=rtcRtpTransceiver;}replaceTransceiver(newRtcRtpTransceiver){this._rtcRtpTransceiver=newRtcRtpTransceiver;}get receiver(){return this._rtcRtpTransceiver.receiver;}get sender(){return this._rtcRtpTransceiver.sender;}get mid(){return this._rtcRtpTransceiver.mid;}close(){this._rtcRtpTransceiver.stop();}}class ReceiveOnlyTransceiver extends Transceiver{constructor(rtcRtpTransceiver,idGetter){super(rtcRtpTransceiver);this._receiveSlot=new ReceiveSlot(()=>{if(!this._rtcRtpTransceiver.mid){return null;}return idGetter(this._rtcRtpTransceiver.mid);},this._rtcRtpTransceiver.receiver.track);}replaceTransceiver(newRtcRtpTransceiver){super.replaceTransceiver(newRtcRtpTransceiver);this._receiveSlot.replaceTrack(newRtcRtpTransceiver.receiver.track);}close(){super.close();this._receiveSlot.close();}get receiveSlot(){return this._receiveSlot;}getStats(){return this.receiver.getStats();}}ReceiveOnlyTransceiver.rid='1';function deepCopy(source){return Array.isArray(source)?source.map(item=>deepCopy(item)):source instanceof Map?new Map(source):source instanceof Date?new Date(source.getTime()):source&&typeof source==='object'?Object.getOwnPropertyNames(source).reduce((o,prop)=>{Object.defineProperty(o,prop,Object.getOwnPropertyDescriptor(source,prop));o[prop]=deepCopy(source[prop]);return o;},Object.create(Object.getPrototypeOf(source))):source;}function matchMlinesInAnswer(parsedOffer,parsedAnswer,streamSignalerManager){parsedAnswer.session.groups=parsedOffer.session.groups;parsedAnswer.media=parsedOffer.media.map(offerMline=>{if(!offerMline.mid){throw new Error("Offer mline is missing MID");}var answerMline=parsedAnswer.media.find(m=>m.mid===offerMline.mid);if(answerMline){if(answerMline instanceof AvMediaDescription){[...answerMline.codecs.values()].forEach(ci=>{ci.fmtParams.set('x-google-start-bitrate','60000');});}return answerMline;}if(!(offerMline instanceof AvMediaDescription)){throw new Error("Answer is missing a non-media mline: ".concat(offerMline.mid));}var startingMline=parsedAnswer.avMedia.find(m=>m.type===offerMline.type);if(!startingMline){throw new Error("Answer has no mline of type ".concat(offerMline.type,", can't generate synthetic answer mline for mid ").concat(offerMline.mid));}var fakeCorrespondingMline=deepCopy(startingMline);fakeCorrespondingMline.mid=offerMline.mid;fakeCorrespondingMline.simulcast=undefined;if(offerMline.direction==='sendrecv'||offerMline.direction==='sendonly'){fakeCorrespondingMline.direction='recvonly';}if(offerMline.direction==='recvonly'){fakeCorrespondingMline.direction='sendonly';var ingressSignaler=streamSignalerManager.getIngressStreamSignalerOrThrow(offerMline.mid);ingressSignaler.signalRemoteStreams(fakeCorrespondingMline);}return fakeCorrespondingMline;});}class JmpLine extends Line{constructor(versions){super();this.versions=versions;}static fromSdpLine(line){if(!JmpLine.regex.test(line)){return undefined;}var tokens=line.match(JmpLine.regex);var versions=tokens[1].split(',').filter(v=>v.length);return new JmpLine(versions);}toSdpLine(){return "a=jmp:".concat(this.versions.join(','));}}JmpLine.regex=/^jmp:((?:v\d+,?)+)/;class JmpStreamIdModeLine extends Line{constructor(streamIdMode){super();this.streamIdMode=streamIdMode;}static fromSdpLine(line){if(!JmpStreamIdModeLine.regex.test(line)){return undefined;}var tokens=line.match(JmpStreamIdModeLine.regex);var mode=tokens[1];return new JmpStreamIdModeLine(mode);}toSdpLine(){return "a=jmp-stream-id-mode:".concat(this.streamIdMode);}}JmpStreamIdModeLine.regex=/^jmp-stream-id-mode:(MID-RID|SSRC)$/;class JmpSourceLine extends Line{constructor(source,csi){super();this.source=source;this.csi=csi;}static fromSdpLine(line){if(!JmpSourceLine.regex.test(line)){return undefined;}var tokens=line.match(JmpSourceLine.regex);var source=tokens[1];var csi=tokens[2];return new JmpSourceLine(source,csi);}toSdpLine(){var line="a=jmp-source:".concat(this.source);if(this.csi){line+=" csi=".concat(this.csi);}return line;}}JmpSourceLine.regex=new RegExp("^jmp-source:(".concat(ANY_NON_WS,") (?:csi=(").concat(ANY_NON_WS,"))"));DefaultSdpGrammar.addParser('a',JmpLine.fromSdpLine);DefaultSdpGrammar.addParser('a',JmpSourceLine.fromSdpLine);DefaultSdpGrammar.addParser('a',JmpStreamIdModeLine.fromSdpLine);function getMediaTypeForMline(mLine){var _a,_b;var mediaFamily;if(mLine.type.toLowerCase()===MediaFamily.Audio.toLowerCase()){mediaFamily=MediaFamily.Audio;}else if(mLine.type.toLowerCase()===MediaFamily.Video.toLowerCase()){mediaFamily=MediaFamily.Video;}else {throw Error("Mline type doesn't match any known MediaFamily: ".concat(mLine.type));}var mediaContent;if((_b=(_a=mLine.content)===null||_a===void 0?void 0:_a.values)===null||_b===void 0?void 0:_b.some(v=>v.toLowerCase()==='slides')){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}return getMediaType(mediaFamily,mediaContent);}function filterCodecs(parsedSdp,allowedCodecs){var allowedLowerCase=allowedCodecs.map(s=>s.toLowerCase());parsedSdp.avMedia.map(m=>[...m.codecs.values()].map(c=>c.name)).flat().filter(codecName=>!allowedLowerCase.includes(codecName.toLowerCase())).forEach(c=>removeCodec(parsedSdp,c));}function setMaxBandwidth(parsedSdp,maxBandwidth){parsedSdp.avMedia.forEach(mline=>{mline.bandwidth=new BandwidthLine('TIAS',maxBandwidth);});}function setupBundle(parsedSdp,bundlePolicy,midMap){if(bundlePolicy==='max-compat'){var audioMainMids=midMap.get(MediaType.AudioMain);var videoMainMids=midMap.get(MediaType.VideoMain);var audioContentMids=midMap.get(MediaType.AudioSlides);var videoContentMids=midMap.get(MediaType.VideoSlides);parsedSdp.session.groups.splice(0,parsedSdp.session.groups.length);if(audioMainMids){parsedSdp.session.groups.push(new BundleGroupLine(audioMainMids));}if(videoMainMids){parsedSdp.session.groups.push(new BundleGroupLine(videoMainMids));}if(audioContentMids){parsedSdp.session.groups.push(new BundleGroupLine(audioContentMids));}if(videoContentMids){parsedSdp.session.groups.push(new BundleGroupLine(videoContentMids));}}}function filterRecvOnlyMlines(parsedSdp){var filteredMids=[];parsedSdp.media=parsedSdp.media.filter(mLine=>{if(mLine instanceof ApplicationMediaDescription||mLine instanceof AvMediaDescription&&mLine.direction!=='recvonly'){filteredMids.push(mLine.mid);return true;}return false;});parsedSdp.session.groups.forEach(g=>{g.mids=g.mids.filter(m=>filteredMids.includes(m));});}function injectContentTypes(sdp,contentTypeMap){contentTypeMap.forEach((mediaContent,mid)=>{var mline=sdp.media.find(m=>m.mid===mid);if(!mline){throw new Error("Error trying to set content type for mid ".concat(mid,": not found in SDP"));}if(mediaContent===MediaContent$1.Slides){mline.addLine(new ContentLine(['slides']));}});}function injectJmpAttributes(parsedSdp,csiMap,streamSignalingMode){parsedSdp.avMedia.filter(mLine=>mLine.direction==='sendrecv'||mLine.direction==='inactive').forEach(mLine=>{if(!mLine.otherLines.find(line=>line instanceof JmpLine)){mLine.addLine(new JmpLine(['v1']));}if(!mLine.otherLines.find(line=>line instanceof JmpSourceLine)){var mediaType=getMediaTypeForMline(mLine);var csi=csiMap.get(mediaType);if(!csi){throw new Error("Unable to find CSI for MediaType ".concat(mediaType));}mLine.addLine(new JmpSourceLine(mLine.mid,csi.toString()));}if(!mLine.otherLines.find(line=>line instanceof JmpStreamIdModeLine)){mLine.addLine(new JmpStreamIdModeLine(streamSignalingMode));}});}function injectDummyCandidates(parsedSdp){parsedSdp.media.forEach(mLine=>{if(mLine.iceInfo.candidates.length===0){mLine.addLine(new CandidateLine('dummy1',1,'udp',1,'0.0.0.0',1,'host'));mLine.addLine(new CandidateLine('dummy2',2,'tcp',2,'0.0.0.0',2,'host'));mLine.addLine(new CandidateLine('dummy3',3,'udp',3,'0.0.0.0',3,'relay'));}});}function hasSimulcast(av){return !!av.simulcast||av.ssrcGroups.map(sg=>sg.semantics).some(sem=>sem==='SIM');}function addVlaExtension(mLine){var vlaUri='http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00';if(mLine.extMaps.findIndex(extMapLine=>extMapLine.uri===vlaUri)===-1){var maxIdValue=Math.max(...mLine.extMaps.map(extMapLine=>extMapLine.id),0);var videoLayersAllocationLine=new ExtMapLine(maxIdValue+1,vlaUri,undefined);mLine.extMaps.push(videoLayersAllocationLine);}}class SendOnlyTransceiver extends Transceiver{constructor(rtcpRtpTransceiver,csi){super(rtcpRtpTransceiver);this.requested=false;this.csi=csi;this.direction='sendrecv';this.handleTrackChange=this.handleTrackChange.bind(this);}handleTrackChange(){var _a;return __awaiter(this,void 0,void 0,function*(){if(this.requested){yield this.sender.replaceTrack(((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null);}});}replaceTransceiver(newRtcRtpTransceiver){var _super=Object.create(null,{replaceTransceiver:{get:()=>super.replaceTransceiver}});var _a;return __awaiter(this,void 0,void 0,function*(){_super.replaceTransceiver.call(this,newRtcRtpTransceiver);newRtcRtpTransceiver.direction=this.direction;if(this.requested){yield this.sender.replaceTrack(((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null);}});}replacePublishedTrack(newTrack){var _a,_b;return __awaiter(this,void 0,void 0,function*(){(_a=this.publishedTrack)===null||_a===void 0?void 0:_a.off(exports.LocalTrackEvents.UnderlyingTrackChange,this.handleTrackChange);(_b=this.publishedTrack)===null||_b===void 0?void 0:_b.setPublished(false);if(this.requested){yield this.sender.replaceTrack((newTrack===null||newTrack===void 0?void 0:newTrack.underlyingTrack)||null);}this.publishedTrack=newTrack;newTrack===null||newTrack===void 0?void 0:newTrack.on(exports.LocalTrackEvents.UnderlyingTrackChange,this.handleTrackChange);newTrack===null||newTrack===void 0?void 0:newTrack.setPublished(true);});}setTrackRequested(requested){var _a;return __awaiter(this,void 0,void 0,function*(){if(this.requested!==requested){this.requested=requested;var newTrack=requested?((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null:null;yield this.sender.replaceTrack(newTrack);}});}publishTrack(track){return this.replacePublishedTrack(track);}unpublishTrack(){return this.replacePublishedTrack();}setActive(enabled){this.direction=enabled?'sendrecv':'inactive';this._rtcRtpTransceiver.direction=this.direction;return this._rtcRtpTransceiver.direction!==this._rtcRtpTransceiver.currentDirection;}getStats(){return this.sender.getStats();}updateSendParameters(requestedIdEncodingParamsMap){return __awaiter(this,void 0,void 0,function*(){var sendParameters=this.sender.getParameters();sendParameters.encodings.forEach((encoding,index)=>{var encodingParams=requestedIdEncodingParamsMap.get(index);encoding.active=!!encodingParams;if(encodingParams){var{maxPayloadBitsPerSecond,scaleDownRatio}=encodingParams;if(maxPayloadBitsPerSecond!==undefined&&maxPayloadBitsPerSecond>=0){encoding.maxBitrate=maxPayloadBitsPerSecond;}if(scaleDownRatio!==undefined&&scaleDownRatio>=1.0){encoding.scaleResolutionDownBy=scaleDownRatio;}}});yield this.sender.setParameters(sendParameters);});}}class StatsManager{constructor(statsGetter){var statsPreprocessor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:()=>__awaiter(this,void 0,void 0,function*(){});this.statsGetter=statsGetter;this.statsPreProcessor=statsPreprocessor;}getStats(){return __awaiter(this,void 0,void 0,function*(){var statsReport=yield this.statsGetter();var statsMap=new Map();statsReport.forEach((stats,key)=>statsMap.set(key,stats));yield this.statsPreProcessor(statsMap);return statsMap;});}}var simulcastMaxFrameSizes={0:'240',1:'2304',2:'8160'};class RidIngressStreamSignaler{constructor(mid){this.mid=mid;}getReceiverId(){return {mid:this.mid,rid:'1'};}signalLocalStreams(mLine){}signalRemoteStreams(mLine){}}class RidEgressStreamSignaler{constructor(mid){this.streamIds=[];this.mid=mid;}signalStreams(simulcastEnabled,_rtxEnabled,mLine){mLine.ssrcGroups=[];if(this.streamIds.length===0){if(simulcastEnabled){this.streamIds=[{mid:this.mid,rid:'low'},{mid:this.mid,rid:'medium'},{mid:this.mid,rid:'high'}];}else {this.streamIds=[{mid:this.mid}];}}if(simulcastEnabled){mLine.rids=this.streamIds.map((streamId,index)=>new RidLine(streamId.rid,'send',"max-fs=".concat(simulcastMaxFrameSizes[index])));mLine.simulcast=new SimulcastLine(SimulcastLayerList.fromString('low;medium;high'),new SimulcastLayerList());addVlaExtension(mLine);}}getSenderIds(){return this.streamIds;}getEncodingIndexForStreamId(streamId){return this.streamIds.findIndex(currStreamId=>compareStreamIds(currStreamId,streamId));}}function generateSsrc(){return Math.floor(Math.random()*0xffffffff)+1;}class SsrcIngressStreamSignaler{constructor(){this.ssrc=generateSsrc();}getReceiverId(){return Object.assign({ssrc:this.ssrc},this.rtxSsrc?{rtxSsrc:this.rtxSsrc}:{});}signalLocalStreams(mLine){mLine.extMaps=mLine.extMaps.filter(extMapLine=>!/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri));}signalRemoteStreams(mLine){mLine.addLine(new SsrcLine(this.ssrc,'cname',"".concat(this.ssrc,"-cname")));mLine.addLine(new SsrcLine(this.ssrc,'msid','-','1'));if(hasCodec('rtx',mLine)){if(!this.rtxSsrc){this.rtxSsrc=generateSsrc();}mLine.addLine(new SsrcLine(this.rtxSsrc,'cname',"".concat(this.ssrc,"-cname")));mLine.addLine(new SsrcLine(this.rtxSsrc,'msid','-','1'));mLine.addLine(new SsrcGroupLine('FID',[this.ssrc,this.rtxSsrc]));}}}class SsrcEgressStreamSignaler{constructor(){this.streamIds=[];}signalStreams(simulcastEnabled,rtxEnabled,mLine){var _a;mLine.rids=[];mLine.simulcast=undefined;mLine.extMaps=mLine.extMaps.filter(extMapLine=>!/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri));var numStreams=simulcastEnabled?3:1;if(!this.streamIds.length){if(mLine.ssrcs.length){var ssrcs=[...new Set(mLine.ssrcs.map(ssrcLine=>ssrcLine.ssrcId))];mLine.ssrcGroups.forEach(sg=>{if(!sg.ssrcs.every(ssrc=>ssrcs.includes(ssrc))){throw new Error('SSRC present in SSRC groups is missing from SSRC lines');}});var rtxSsrcGroups=mLine.ssrcGroups.filter(sg=>sg.semantics==='FID');if(rtxSsrcGroups.length&&rtxSsrcGroups.length!==numStreams){throw new Error("Expect ".concat(numStreams," RTX SSRC groups, got ").concat(rtxSsrcGroups.length));}rtxSsrcGroups.forEach(sg=>{this.streamIds.push({ssrc:sg.ssrcs[0],rtxSsrc:sg.ssrcs[1]});});var simulcastSsrcs=(_a=mLine.ssrcGroups.find(sg=>sg.semantics==='SIM'))===null||_a===void 0?void 0:_a.ssrcs;if(simulcastSsrcs){if(simulcastSsrcs.length!==numStreams||!this.streamIds.every(streamId=>simulcastSsrcs.includes(streamId.ssrc))){throw new Error('SSRCs in simulcast SSRC group do not match primary SSRCs in RTX SSRC groups');}this.streamIds.sort((a,b)=>simulcastSsrcs.indexOf(a.ssrc)-simulcastSsrcs.indexOf(b.ssrc));}else if(rtxSsrcGroups.length>1){throw new Error('Multiple RTX SSRC groups but no simulcast SSRC group found');}if(!this.streamIds.length){this.streamIds.push({ssrc:ssrcs[0]});}}else {[...Array(numStreams).keys()].forEach(()=>{var newStreamId={ssrc:generateSsrc()};if(rtxEnabled){newStreamId.rtxSsrc=generateSsrc();}this.streamIds.push(newStreamId);});}}mLine.ssrcs=[];mLine.ssrcGroups=[];this.streamIds.forEach(streamId=>{var rtpSsrc=streamId.ssrc;mLine.addLine(new SsrcLine(rtpSsrc,'cname',"".concat(rtpSsrc,"-cname")));mLine.addLine(new SsrcLine(rtpSsrc,'msid','-','1'));if(rtxEnabled){var rtxSsrc=streamId.rtxSsrc;mLine.addLine(new SsrcLine(rtxSsrc,'cname',"".concat(rtpSsrc,"-cname")));mLine.addLine(new SsrcLine(rtxSsrc,'msid','-','1'));mLine.addLine(new SsrcGroupLine('FID',[rtpSsrc,rtxSsrc]));}});if(simulcastEnabled){mLine.addLine(new SsrcGroupLine('SIM',this.streamIds.map(streamId=>streamId.ssrc)));addVlaExtension(mLine);}}getSenderIds(){return this.streamIds;}getEncodingIndexForStreamId(streamId){return this.streamIds.findIndex(currStreamId=>compareStreamIds(currStreamId,streamId));}}class StreamSignalerManager{constructor(streamSignalingMode){this.egressStreamSignalersByMid=new Map();this.ingressStreamsSignalersByMid=new Map();this.ingressStreamSignalingMode=streamSignalingMode;this.egressStreamSignalingMode=streamSignalingMode;}getOrCreateEgressStreamSignaler(mid){var existing=this.getEgressStreamSignaler(mid);if(existing){return existing;}var newSignaler;if(this.egressStreamSignalingMode==='MID-RID'){newSignaler=new RidEgressStreamSignaler(mid);}else {newSignaler=new SsrcEgressStreamSignaler();}this.egressStreamSignalersByMid.set(mid,newSignaler);return newSignaler;}getEgressStreamSignalerOrThrow(mid){var existing=this.getEgressStreamSignaler(mid);if(!existing){throw new Error("Couldn't find EgressStreamSignaler for mid ".concat(mid));}return existing;}getEgressStreamSignaler(mid){return this.egressStreamSignalersByMid.get(mid);}getOrCreateIngressStreamSignaler(mid){var existing=this.getIngressStreamSignaler(mid);if(existing){return existing;}var newSignaler;if(this.ingressStreamSignalingMode==='MID-RID'){newSignaler=new RidIngressStreamSignaler(mid);}else {newSignaler=new SsrcIngressStreamSignaler();}this.ingressStreamsSignalersByMid.set(mid,newSignaler);return newSignaler;}getIngressStreamSignaler(mid){return this.ingressStreamsSignalersByMid.get(mid);}getIngressStreamSignalerOrThrow(mid){var existing=this.getIngressStreamSignaler(mid);if(!existing){throw new Error("Couldn't find IngressStreamSignaler for mid ".concat(mid));}return existing;}}var organizeTransceiverStats=(sendTransceivers,recvTransceivers)=>__awaiter(void 0,void 0,void 0,function*(){var result={audio:{senders:[],receivers:[]},video:{senders:[],receivers:[]},screenShareAudio:{senders:[],receivers:[]},screenShareVideo:{senders:[],receivers:[]}};yield Promise.all([...sendTransceivers.entries()].map(_ref3=>{var[mediaType,transceiver]=_ref3;return __awaiter(void 0,void 0,void 0,function*(){var _a;var item={report:yield transceiver.getStats(),mid:transceiver.mid,csi:transceiver.csi,currentDirection:'sendonly',localTrackLabel:(_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.label};if(mediaType===MediaType.AudioMain){result.audio.senders.push(item);}if(mediaType===MediaType.VideoMain){result.video.senders.push(item);}if(mediaType===MediaType.AudioSlides){result.screenShareAudio.senders.push(item);}if(mediaType===MediaType.VideoSlides){result.screenShareVideo.senders.push(item);}});}));yield Promise.all([...recvTransceivers.entries()].map(_ref4=>{var[mediaType,transceivers]=_ref4;return __awaiter(void 0,void 0,void 0,function*(){return Promise.all(transceivers.map(t=>__awaiter(void 0,void 0,void 0,function*(){var _b,_c;var item={report:yield t.getStats(),mid:(_b=t.receiveSlot.id)===null||_b===void 0?void 0:_b.mid,csi:t.receiveSlot.currentRxCsi,currentDirection:'recvonly',localTrackLabel:(_c=t.receiveSlot.stream.getTracks()[0])===null||_c===void 0?void 0:_c.label};if(mediaType===MediaType.AudioMain){result.audio.receivers.push(item);}if(mediaType===MediaType.VideoMain){result.video.receivers.push(item);}if(mediaType===MediaType.AudioSlides){result.screenShareAudio.receivers.push(item);}if(mediaType===MediaType.VideoSlides){result.screenShareVideo.receivers.push(item);}})));});}));return result;});var es5={exports:{}};(function(module,exports){!function(e,t){module.exports=t();}(commonjsGlobal$3,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 o(){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 get(){return s.BROWSER_MAP;}},{key:"ENGINE_MAP",get:function get(){return s.ENGINE_MAP;}},{key:"OS_MAP",get:function get(){return s.OS_MAP;}},{key:"PLATFORMS_MAP",get:function get(){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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t;}},{test:function test(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r;},describe:function describe(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/playstation 4/i],describe:function describe(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/safari|applewebkit/i],describe:function describe(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/.*/i],describe:function describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 test(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r;},describe:function describe(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 describe(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 describe(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 describe(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Bada,version:t};}},{test:[/tizen/i],describe:function describe(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 describe(){return {name:s.OS_MAP.Linux};}},{test:[/CrOS/],describe:function describe(){return {name:s.OS_MAP.ChromeOS};}},{test:[/PlayStation 4/],describe:function describe(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 describe(){return {type:"bot",vendor:"Google"};}},{test:[/huawei/i],describe:function describe(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 describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"};}},{test:[/ipad/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"};}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"};}},{test:[/kftt build/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"};}},{test:[/silk/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"};}},{test:[/tablet(?! pc)/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet};}},{test:function test(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r;},describe:function describe(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 describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"};}},{test:[/[^-]mobi/i],describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "blackberry"===e.getBrowserName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"};}},{test:function test(e){return "bada"===e.getBrowserName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "windows phone"===e.getBrowserName();},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"};}},{test:function test(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return "android"===e.getOSName(!0)&&t>=3;},describe:function describe(){return {type:s.PLATFORMS_MAP.tablet};}},{test:function test(e){return "android"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "macos"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop,vendor:"Apple"};}},{test:function test(e){return "windows"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop};}},{test:function test(e){return "linux"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop};}},{test:function test(e){return "playstation 4"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.tv};}},{test:function test(e){return "roku"===e.getOSName(!0);},describe:function describe(){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 test(e){return "microsoft edge"===e.getBrowserName(!0);},describe:function describe(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 describe(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 test(e){return e.test(/presto/i);},describe:function describe(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 test(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r;},describe:function describe(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 describe(){return {name:s.ENGINE_MAP.Blink};}},{test:[/(apple)?webkit/i],describe:function describe(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;}});});})(es5);var Bowser=/*@__PURE__*/getDefaultExportFromCjs(es5.exports);function getBrowserDetails(){var browser=Bowser.getParser(window.navigator.userAgent);return browser.getBrowser();}/**
|
|
3818
|
+
if(flags.once){emitter.removeEventListener(name,wrapListener);}listener(arg);});}else {throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof emitter);}}class EventEmitter extends events.exports.EventEmitter{}class MidPredictor{constructor(){this.currentMid=0;this.midMap=new Map();}getNextMid(mediaType){var mid=this.currentMid++;var mids=this.midMap.get(mediaType)||[];mids.push("".concat(mid));this.midMap.set(mediaType,mids);return "".concat(mid);}allocateMidForDatachannel(){this.currentMid+=1;}reset(){this.midMap=new Map();this.currentMid=0;}getMidMap(){return this.midMap;}}var OveruseState;(function(OveruseState){OveruseState[OveruseState["NOT_OVERUSED"]=0]="NOT_OVERUSED";OveruseState[OveruseState["OVERUSED"]=1]="OVERUSED";})(OveruseState||(OveruseState={}));class OveruseStateManager{constructor(callback){this.monitors=[];this.lastOverallOveruseState=OveruseState.NOT_OVERUSED;this.isRunning=false;this.overuseUpdateCallback=callback;}addMonitor(monitor){this.monitors.push(monitor);if(this.isRunning){monitor.startMonitoring(()=>this.onMonitorOveruseUpdate());}}start(){this.isRunning=true;this.monitors.forEach(monitor=>monitor.startMonitoring(()=>this.onMonitorOveruseUpdate()));}stop(){this.isRunning=false;this.monitors.forEach(monitor=>monitor.stopMonitoring());}onMonitorOveruseUpdate(){var overuseStates=this.monitors.map(monitor=>monitor.getLastOveruseState());var overallOveruseState=overuseStates.some(overuseState=>overuseState===OveruseState.OVERUSED)?OveruseState.OVERUSED:OveruseState.NOT_OVERUSED;if(overallOveruseState!==this.lastOverallOveruseState){this.lastOverallOveruseState=overallOveruseState;this.overuseUpdateCallback(overallOveruseState);}}}exports.ReceiveSlotEvents = void 0;(function(ReceiveSlotEvents){ReceiveSlotEvents["MediaStarted"]="media-started";ReceiveSlotEvents["MediaStopped"]="media-stopped";ReceiveSlotEvents["SourceUpdate"]="source-update";})(exports.ReceiveSlotEvents||(exports.ReceiveSlotEvents={}));class ReceiveSlot extends EventEmitter{constructor(idGetter,track){super();this._idGetter=idGetter;this.handleTrackMuted=this.handleTrackMuted.bind(this);this.handleTrackUnmuted=this.handleTrackUnmuted.bind(this);this._stream=new MediaStream([track]);this._sourceState='no source';this.addTrackHandlers(track);}addTrackHandlers(track){track.addEventListener('mute',this.handleTrackMuted);track.addEventListener('unmute',this.handleTrackUnmuted);}handleTrackMuted(){this.emit(exports.ReceiveSlotEvents.MediaStopped);}handleTrackUnmuted(){this.emit(exports.ReceiveSlotEvents.MediaStarted);}removeTrackHandlers(track){track.removeEventListener('mute',this.handleTrackMuted);track.removeEventListener('unmute',this.handleTrackUnmuted);}replaceTrack(newTrack){var _a;var trackToRemove=(_a=this._stream.getTracks())===null||_a===void 0?void 0:_a[0];if(trackToRemove){this._stream.removeTrack(trackToRemove);this.removeTrackHandlers(trackToRemove);}this.addTrackHandlers(newTrack);this._stream.addTrack(newTrack);}_updateSource(state,csi){if(state!==this._sourceState||csi!==this._currentRxCsi){this._sourceState=state;this._currentRxCsi=csi;this.emit(exports.ReceiveSlotEvents.SourceUpdate,state,csi);}}close(){this._stream.getTracks().forEach(t=>{this.removeTrackHandlers(t);});}get id(){return this._idGetter();}get stream(){return this._stream;}get currentRxCsi(){return this._currentRxCsi;}}ReceiveSlot.Events=exports.ReceiveSlotEvents;class Transceiver{constructor(rtcRtpTransceiver,mid){this._rtcRtpTransceiver=rtcRtpTransceiver;this.mid=mid;}replaceTransceiver(newRtcRtpTransceiver){this._rtcRtpTransceiver=newRtcRtpTransceiver;}get receiver(){return this._rtcRtpTransceiver.receiver;}get sender(){return this._rtcRtpTransceiver.sender;}close(){this._rtcRtpTransceiver.stop();}}class ReceiveOnlyTransceiver extends Transceiver{constructor(rtcRtpTransceiver,mid,signaler){super(rtcRtpTransceiver,mid);this.streamSignaler=signaler;this._receiveSlot=new ReceiveSlot(()=>{if(!this._rtcRtpTransceiver.mid){return null;}return this.streamSignaler.getReceiverId();},this._rtcRtpTransceiver.receiver.track);}replaceTransceiver(newRtcRtpTransceiver){super.replaceTransceiver(newRtcRtpTransceiver);this._receiveSlot.replaceTrack(newRtcRtpTransceiver.receiver.track);}close(){super.close();this._receiveSlot.close();}get receiveSlot(){return this._receiveSlot;}getStats(){return this.receiver.getStats();}signalLocalStreams(mLine){this.streamSignaler.signalLocalStreams(mLine);}signalRemoteStreams(mLine){this.streamSignaler.signalRemoteStreams(mLine);}get receiverId(){return this.streamSignaler.getReceiverId();}resetStreamSignaler(){this.streamSignaler.reset();}}ReceiveOnlyTransceiver.rid='1';class JmpLine extends Line$1{constructor(versions){super();this.versions=versions;}static fromSdpLine(line){if(!JmpLine.regex.test(line)){return undefined;}var tokens=line.match(JmpLine.regex);var versions=tokens[1].split(',').filter(v=>v.length);return new JmpLine(versions);}toSdpLine(){return "a=jmp:".concat(this.versions.join(','));}}JmpLine.regex=/^jmp:((?:v\d+,?)+)/;class JmpStreamIdModeLine extends Line$1{constructor(streamIdMode){super();this.streamIdMode=streamIdMode;}static fromSdpLine(line){if(!JmpStreamIdModeLine.regex.test(line)){return undefined;}var tokens=line.match(JmpStreamIdModeLine.regex);var mode=tokens[1];return new JmpStreamIdModeLine(mode);}toSdpLine(){return "a=jmp-stream-id-mode:".concat(this.streamIdMode);}}JmpStreamIdModeLine.regex=/^jmp-stream-id-mode:(MID-RID|SSRC)$/;class JmpSourceLine extends Line$1{constructor(source,csi){super();this.source=source;this.csi=csi;}static fromSdpLine(line){if(!JmpSourceLine.regex.test(line)){return undefined;}var tokens=line.match(JmpSourceLine.regex);var source=tokens[1];var csi=tokens[2];return new JmpSourceLine(source,csi);}toSdpLine(){var line="a=jmp-source:".concat(this.source);if(this.csi){line+=" csi=".concat(this.csi);}return line;}}JmpSourceLine.regex=new RegExp("^jmp-source:(".concat(ANY_NON_WS$1,") (?:csi=(").concat(ANY_NON_WS$1,"))"));DefaultSdpGrammar$1.addParser('a',JmpLine.fromSdpLine);DefaultSdpGrammar$1.addParser('a',JmpSourceLine.fromSdpLine);DefaultSdpGrammar$1.addParser('a',JmpStreamIdModeLine.fromSdpLine);function getMediaTypeForMline(mLine){var _a,_b;var mediaFamily;if(mLine.type.toLowerCase()===MediaFamily.Audio.toLowerCase()){mediaFamily=MediaFamily.Audio;}else if(mLine.type.toLowerCase()===MediaFamily.Video.toLowerCase()){mediaFamily=MediaFamily.Video;}else {throw Error("Mline type doesn't match any known MediaFamily: ".concat(mLine.type));}var mediaContent;if((_b=(_a=mLine.content)===null||_a===void 0?void 0:_a.values)===null||_b===void 0?void 0:_b.some(v=>v.toLowerCase()==='slides')){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}return getMediaType(mediaFamily,mediaContent);}function filterCodecs(parsedSdp,allowedCodecs){var allowedLowerCase=allowedCodecs.map(s=>s.toLowerCase());parsedSdp.avMedia.map(m=>[...m.codecs.values()].map(c=>c.name)).flat().filter(codecName=>!allowedLowerCase.includes(codecName.toLowerCase())).forEach(c=>removeCodec(parsedSdp,c));}function setMaxBandwidth(parsedSdp,maxBandwidth){parsedSdp.avMedia.forEach(mline=>{mline.bandwidth=new BandwidthLine$1('TIAS',maxBandwidth);});}function setupBundle(parsedSdp,bundlePolicy,midMap){if(bundlePolicy==='max-compat'){var audioMainMids=midMap.get(MediaType.AudioMain);var videoMainMids=midMap.get(MediaType.VideoMain);var audioContentMids=midMap.get(MediaType.AudioSlides);var videoContentMids=midMap.get(MediaType.VideoSlides);parsedSdp.session.groups.splice(0,parsedSdp.session.groups.length);if(audioMainMids){parsedSdp.session.groups.push(new BundleGroupLine$1(audioMainMids));}if(videoMainMids){parsedSdp.session.groups.push(new BundleGroupLine$1(videoMainMids));}if(audioContentMids){parsedSdp.session.groups.push(new BundleGroupLine$1(audioContentMids));}if(videoContentMids){parsedSdp.session.groups.push(new BundleGroupLine$1(videoContentMids));}}}function filterRecvOnlyMlines(parsedSdp){var filteredMids=[];parsedSdp.media=parsedSdp.media.filter(mLine=>{if(mLine instanceof ApplicationMediaDescription$1||mLine instanceof AvMediaDescription$1&&mLine.direction!=='recvonly'){filteredMids.push(mLine.mid);return true;}return false;});parsedSdp.session.groups.forEach(g=>{g.mids=g.mids.filter(m=>filteredMids.includes(m));});}function injectContentTypes(sdp,contentTypeMap){contentTypeMap.forEach((mediaContent,mid)=>{var mline=sdp.media.find(m=>m.mid===mid);if(!mline){throw new Error("Error trying to set content type for mid ".concat(mid,": not found in SDP"));}if(mediaContent===MediaContent$1.Slides){mline.addLine(new ContentLine$1(['slides']));}});}function injectJmpAttributes(parsedSdp,csiMap,streamSignalingMode){parsedSdp.avMedia.filter(mLine=>mLine.direction==='sendrecv'||mLine.direction==='inactive').forEach(mLine=>{if(!mLine.otherLines.find(line=>line instanceof JmpLine)){mLine.addLine(new JmpLine(['v1']));}if(!mLine.otherLines.find(line=>line instanceof JmpSourceLine)){var mediaType=getMediaTypeForMline(mLine);var csi=csiMap.get(mediaType);if(!csi){throw new Error("Unable to find CSI for MediaType ".concat(mediaType));}mLine.addLine(new JmpSourceLine(mLine.mid,csi.toString()));}if(!mLine.otherLines.find(line=>line instanceof JmpStreamIdModeLine)){mLine.addLine(new JmpStreamIdModeLine(streamSignalingMode));}});}function injectDummyCandidates(parsedSdp){parsedSdp.media.forEach(mLine=>{if(mLine.iceInfo.candidates.length===0){mLine.addLine(new CandidateLine$1('dummy1',1,'udp',1,'0.0.0.0',1,'host'));mLine.addLine(new CandidateLine$1('dummy2',2,'tcp',2,'0.0.0.0',2,'host'));mLine.addLine(new CandidateLine$1('dummy3',3,'udp',3,'0.0.0.0',3,'relay'));}});}function addVlaExtension(mLine){var vlaUri='http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00';if(mLine.extMaps.findIndex(extMapLine=>extMapLine.uri===vlaUri)===-1){var maxIdValue=Math.max(...mLine.extMaps.map(extMapLine=>extMapLine.id),0);var videoLayersAllocationLine=new ExtMapLine$1(maxIdValue+1,vlaUri,undefined);mLine.extMaps.push(videoLayersAllocationLine);}}var simulcastMaxFrameSizes={0:'240',1:'2304',2:'8160'};class RidIngressStreamSignaler{constructor(mid){this.mid=mid;}getReceiverId(){return {mid:this.mid,rid:'1'};}signalLocalStreams(mLine){}signalRemoteStreams(mLine){}reset(){}}class RidEgressStreamSignaler{constructor(mid){this.streamIds=[];this.mid=mid;}signalStreams(simulcastEnabled,_rtxEnabled,mLine){mLine.ssrcGroups=[];if(this.streamIds.length===0){if(simulcastEnabled){this.streamIds=[{mid:this.mid,rid:'low'},{mid:this.mid,rid:'medium'},{mid:this.mid,rid:'high'}];}else {this.streamIds=[{mid:this.mid}];}}if(simulcastEnabled){mLine.rids=this.streamIds.map((streamId,index)=>new RidLine$1(streamId.rid,'send',"max-fs=".concat(simulcastMaxFrameSizes[index])));mLine.simulcast=new SimulcastLine$1(SimulcastLayerList$1.fromString('low;medium;high'),new SimulcastLayerList$1());addVlaExtension(mLine);}}getSenderIds(){return this.streamIds;}reset(){this.streamIds=[];}getEncodingIndexForStreamId(streamId){return this.streamIds.findIndex(currStreamId=>compareStreamIds(currStreamId,streamId));}setCodecParameters(parameters){}deleteCodecParameters(parameters){}}function deepCopy(source){return Array.isArray(source)?source.map(item=>deepCopy(item)):source instanceof Map?new Map(source):source instanceof Date?new Date(source.getTime()):source&&typeof source==='object'?Object.getOwnPropertyNames(source).reduce((o,prop)=>{Object.defineProperty(o,prop,Object.getOwnPropertyDescriptor(source,prop));o[prop]=deepCopy(source[prop]);return o;},Object.create(Object.getPrototypeOf(source))):source;}function matchMlinesInAnswer(parsedOffer,parsedAnswer,recvTransceiversByMid){parsedAnswer.session.groups=parsedOffer.session.groups;parsedAnswer.media=parsedOffer.media.map(offerMline=>{if(!offerMline.mid){throw new Error("Offer mline is missing MID");}var answerMline=parsedAnswer.media.find(m=>m.mid===offerMline.mid);if(answerMline){if(answerMline instanceof AvMediaDescription$1){[...answerMline.codecs.values()].forEach(ci=>{ci.fmtParams.set('x-google-start-bitrate','60000');});}return answerMline;}if(!(offerMline instanceof AvMediaDescription$1)){throw new Error("Answer is missing a non-media mline: ".concat(offerMline.mid));}var startingMline=parsedAnswer.avMedia.find(m=>m.type===offerMline.type);if(!startingMline){throw new Error("Answer has no mline of type ".concat(offerMline.type,", can't generate synthetic answer mline for mid ").concat(offerMline.mid));}var fakeCorrespondingMline=deepCopy(startingMline);fakeCorrespondingMline.mid=offerMline.mid;fakeCorrespondingMline.simulcast=undefined;if(offerMline.direction==='sendrecv'||offerMline.direction==='sendonly'){fakeCorrespondingMline.direction='recvonly';}if(offerMline.direction==='recvonly'){fakeCorrespondingMline.direction='sendonly';var recvTransceiver=recvTransceiversByMid.get(offerMline.mid);if(!recvTransceiver){throw new Error("Can't find recv transceiver for mid ".concat(offerMline.mid));}recvTransceiver.signalRemoteStreams(fakeCorrespondingMline);}return fakeCorrespondingMline;});}class SendOnlyTransceiver extends Transceiver{constructor(rtcpRtpTransceiver,mid,csi,signaler){super(rtcpRtpTransceiver,mid);this.rtxEnabled=false;this.requested=false;this.csi=csi;this.direction='sendrecv';this.handleTrackChange=this.handleTrackChange.bind(this);this.streamSignaler=signaler;}handleTrackChange(){var _a;return __awaiter(this,void 0,void 0,function*(){if(this.requested){yield this.sender.replaceTrack(((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null);}});}replaceTransceiver(newRtcRtpTransceiver){var _super=Object.create(null,{replaceTransceiver:{get:()=>super.replaceTransceiver}});var _a;return __awaiter(this,void 0,void 0,function*(){_super.replaceTransceiver.call(this,newRtcRtpTransceiver);newRtcRtpTransceiver.direction=this.direction;if(this.requested){yield this.sender.replaceTrack(((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null);}});}replacePublishedTrack(newTrack){var _a,_b;return __awaiter(this,void 0,void 0,function*(){(_a=this.publishedTrack)===null||_a===void 0?void 0:_a.off(exports.LocalTrackEvents.UnderlyingTrackChange,this.handleTrackChange);(_b=this.publishedTrack)===null||_b===void 0?void 0:_b.setPublished(false);if(this.requested){yield this.sender.replaceTrack((newTrack===null||newTrack===void 0?void 0:newTrack.underlyingTrack)||null);}this.publishedTrack=newTrack;newTrack===null||newTrack===void 0?void 0:newTrack.on(exports.LocalTrackEvents.UnderlyingTrackChange,this.handleTrackChange);newTrack===null||newTrack===void 0?void 0:newTrack.setPublished(true);});}setTrackRequested(requested){var _a;return __awaiter(this,void 0,void 0,function*(){if(this.requested!==requested){this.requested=requested;var newTrack=requested?((_a=this.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack)||null:null;yield this.sender.replaceTrack(newTrack);}});}publishTrack(track){return this.replacePublishedTrack(track);}unpublishTrack(){return this.replacePublishedTrack();}setActive(enabled){this.direction=enabled?'sendrecv':'inactive';this._rtcRtpTransceiver.direction=this.direction;return this._rtcRtpTransceiver.direction!==this._rtcRtpTransceiver.currentDirection;}getStats(){return this.sender.getStats();}updateSendParameters(requestedIdEncodingParamsMap){return __awaiter(this,void 0,void 0,function*(){var sendParameters=this.sender.getParameters();sendParameters.encodings.forEach((encoding,index)=>{var encodingParams=requestedIdEncodingParamsMap.get(index);encoding.active=!!encodingParams;if(encodingParams){var{maxPayloadBitsPerSecond,scaleDownRatio}=encodingParams;if(maxPayloadBitsPerSecond!==undefined&&maxPayloadBitsPerSecond>=0){encoding.maxBitrate=maxPayloadBitsPerSecond;}if(scaleDownRatio!==undefined&&scaleDownRatio>=1.0){encoding.scaleResolutionDownBy=scaleDownRatio;}}});yield this.sender.setParameters(sendParameters);});}isSimulcastEnabled(){var params=this.sender.getParameters();return params.encodings.length>1;}signalStreams(mLine){this.streamSignaler.signalStreams(this.isSimulcastEnabled(),this.rtxEnabled,mLine);}get senderIds(){return this.streamSignaler.getSenderIds();}getEncodingIndexForStreamId(id){return this.streamSignaler.getEncodingIndexForStreamId(id);}resetStreamSignaler(){this.streamSignaler.reset();}setCodecParameters(parameters){this.streamSignaler.setCodecParameters(parameters);}deleteCodecParameters(parameters){this.streamSignaler.deleteCodecParameters(parameters);}}function generateSsrc(){return Math.floor(Math.random()*0xffffffff)+1;}function setCustomCodecParams(mLine,paramsMap){paramsMap.forEach((value,param)=>{[...mLine.codecs.values()].filter(ci=>ci.name==='H264'||ci.name==='opus').forEach(ci=>{if(value===null){ci.fmtParams.delete(param);}else {ci.fmtParams.set(param,"".concat(value));}});});}class SsrcIngressStreamSignaler{constructor(){this.ssrc=generateSsrc();}getReceiverId(){return Object.assign({ssrc:this.ssrc},this.rtxSsrc?{rtxSsrc:this.rtxSsrc}:{});}signalLocalStreams(mLine){mLine.extMaps=mLine.extMaps.filter(extMapLine=>!/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri));}signalRemoteStreams(mLine){mLine.addLine(new SsrcLine$1(this.ssrc,'cname',"".concat(this.ssrc,"-cname")));mLine.addLine(new SsrcLine$1(this.ssrc,'msid','-','1'));if(hasCodec('rtx',mLine)){if(!this.rtxSsrc){this.rtxSsrc=generateSsrc();}mLine.addLine(new SsrcLine$1(this.rtxSsrc,'cname',"".concat(this.ssrc,"-cname")));mLine.addLine(new SsrcLine$1(this.rtxSsrc,'msid','-','1'));mLine.addLine(new SsrcGroupLine$1('FID',[this.ssrc,this.rtxSsrc]));}}reset(){this.ssrc=generateSsrc();}}class SsrcEgressStreamSignaler{constructor(){this.streamIds=[];this.customCodecParameters=new Map();}reset(){this.streamIds=[];}signalStreams(simulcastEnabled,rtxEnabled,mLine){var _a;mLine.rids=[];mLine.simulcast=undefined;mLine.extMaps=mLine.extMaps.filter(extMapLine=>!/^urn:ietf:params:rtp-hdrext:sdes:(?:mid|rtp-stream-id|repaired-rtp-stream-id)$/.test(extMapLine.uri));var numStreams=simulcastEnabled?3:1;if(!this.streamIds.length){if(mLine.ssrcs.length){var ssrcs=[...new Set(mLine.ssrcs.map(ssrcLine=>ssrcLine.ssrcId))];mLine.ssrcGroups.forEach(sg=>{if(!sg.ssrcs.every(ssrc=>ssrcs.includes(ssrc))){throw new Error('SSRC present in SSRC groups is missing from SSRC lines');}});var rtxSsrcGroups=mLine.ssrcGroups.filter(sg=>sg.semantics==='FID');if(rtxSsrcGroups.length&&rtxSsrcGroups.length!==numStreams){throw new Error("Expect ".concat(numStreams," RTX SSRC groups, got ").concat(rtxSsrcGroups.length));}rtxSsrcGroups.forEach(sg=>{this.streamIds.push({ssrc:sg.ssrcs[0],rtxSsrc:sg.ssrcs[1]});});var simulcastSsrcs=(_a=mLine.ssrcGroups.find(sg=>sg.semantics==='SIM'))===null||_a===void 0?void 0:_a.ssrcs;if(simulcastSsrcs){if(simulcastSsrcs.length!==numStreams||!this.streamIds.every(streamId=>simulcastSsrcs.includes(streamId.ssrc))){throw new Error('SSRCs in simulcast SSRC group do not match primary SSRCs in RTX SSRC groups');}this.streamIds.sort((a,b)=>simulcastSsrcs.indexOf(a.ssrc)-simulcastSsrcs.indexOf(b.ssrc));}else if(rtxSsrcGroups.length>1){throw new Error('Multiple RTX SSRC groups but no simulcast SSRC group found');}if(!this.streamIds.length){this.streamIds.push({ssrc:ssrcs[0]});}}else {[...Array(numStreams).keys()].forEach(()=>{var newStreamId={ssrc:generateSsrc()};if(rtxEnabled){newStreamId.rtxSsrc=generateSsrc();}this.streamIds.push(newStreamId);});}}mLine.ssrcs=[];mLine.ssrcGroups=[];this.streamIds.forEach(streamId=>{var rtpSsrc=streamId.ssrc;mLine.addLine(new SsrcLine$1(rtpSsrc,'cname',"".concat(rtpSsrc,"-cname")));mLine.addLine(new SsrcLine$1(rtpSsrc,'msid','-','1'));if(rtxEnabled){var rtxSsrc=streamId.rtxSsrc;mLine.addLine(new SsrcLine$1(rtxSsrc,'cname',"".concat(rtpSsrc,"-cname")));mLine.addLine(new SsrcLine$1(rtxSsrc,'msid','-','1'));mLine.addLine(new SsrcGroupLine$1('FID',[rtpSsrc,rtxSsrc]));}});if(simulcastEnabled){mLine.addLine(new SsrcGroupLine$1('SIM',this.streamIds.map(streamId=>streamId.ssrc)));addVlaExtension(mLine);}setCustomCodecParams(mLine,this.customCodecParameters);}getSenderIds(){return this.streamIds;}getEncodingIndexForStreamId(streamId){return this.streamIds.findIndex(currStreamId=>compareStreamIds(currStreamId,streamId));}setCodecParameters(parameters){Object.entries(parameters).forEach(_ref3=>{var[param,value]=_ref3;this.customCodecParameters.set(param,value);});}deleteCodecParameters(parameters){parameters.forEach(param=>{this.customCodecParameters.set(param,null);});}}class StatsManager{constructor(statsGetter){var statsPreprocessor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:()=>__awaiter(this,void 0,void 0,function*(){});this.statsGetter=statsGetter;this.statsPreProcessor=statsPreprocessor;}getStats(){return __awaiter(this,void 0,void 0,function*(){var statsReport=yield this.statsGetter();var statsMap=new Map();statsReport.forEach((stats,key)=>statsMap.set(key,stats));yield this.statsPreProcessor(statsMap);return statsMap;});}}var organizeTransceiverStats=(sendTransceivers,recvTransceivers)=>__awaiter(void 0,void 0,void 0,function*(){var result={audio:{senders:[],receivers:[]},video:{senders:[],receivers:[]},screenShareAudio:{senders:[],receivers:[]},screenShareVideo:{senders:[],receivers:[]}};yield Promise.all([...sendTransceivers.entries()].map(_ref4=>{var[mediaType,transceiver]=_ref4;return __awaiter(void 0,void 0,void 0,function*(){var _a;var item={report:yield transceiver.getStats(),mid:transceiver.mid,csi:transceiver.csi,currentDirection:'sendonly',localTrackLabel:(_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.label};if(mediaType===MediaType.AudioMain){result.audio.senders.push(item);}if(mediaType===MediaType.VideoMain){result.video.senders.push(item);}if(mediaType===MediaType.AudioSlides){result.screenShareAudio.senders.push(item);}if(mediaType===MediaType.VideoSlides){result.screenShareVideo.senders.push(item);}});}));yield Promise.all([...recvTransceivers.entries()].map(_ref5=>{var[mediaType,transceivers]=_ref5;return __awaiter(void 0,void 0,void 0,function*(){return Promise.all(transceivers.map(t=>__awaiter(void 0,void 0,void 0,function*(){var _b,_c;var item={report:yield t.getStats(),mid:(_b=t.receiveSlot.id)===null||_b===void 0?void 0:_b.mid,csi:t.receiveSlot.currentRxCsi,currentDirection:'recvonly',localTrackLabel:(_c=t.receiveSlot.stream.getTracks()[0])===null||_c===void 0?void 0:_c.label};if(mediaType===MediaType.AudioMain){result.audio.receivers.push(item);}if(mediaType===MediaType.VideoMain){result.video.receivers.push(item);}if(mediaType===MediaType.AudioSlides){result.screenShareAudio.receivers.push(item);}if(mediaType===MediaType.VideoSlides){result.screenShareVideo.receivers.push(item);}})));});}));return result;});var es5={exports:{}};(function(module,exports){!function(e,t){module.exports=t();}(commonjsGlobal$3,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 o(){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 get(){return s.BROWSER_MAP;}},{key:"ENGINE_MAP",get:function get(){return s.ENGINE_MAP;}},{key:"OS_MAP",get:function get(){return s.OS_MAP;}},{key:"PLATFORMS_MAP",get:function get(){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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t;}},{test:function test(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r;},describe:function describe(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/playstation 4/i],describe:function describe(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/safari|applewebkit/i],describe:function describe(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t;}},{test:[/.*/i],describe:function describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 describe(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 test(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r;},describe:function describe(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 describe(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 describe(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 describe(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return {name:s.OS_MAP.Bada,version:t};}},{test:[/tizen/i],describe:function describe(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 describe(){return {name:s.OS_MAP.Linux};}},{test:[/CrOS/],describe:function describe(){return {name:s.OS_MAP.ChromeOS};}},{test:[/PlayStation 4/],describe:function describe(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 describe(){return {type:"bot",vendor:"Google"};}},{test:[/huawei/i],describe:function describe(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 describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"};}},{test:[/ipad/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"};}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"};}},{test:[/kftt build/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"};}},{test:[/silk/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"};}},{test:[/tablet(?! pc)/i],describe:function describe(){return {type:s.PLATFORMS_MAP.tablet};}},{test:function test(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r;},describe:function describe(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 describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"};}},{test:[/[^-]mobi/i],describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "blackberry"===e.getBrowserName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"};}},{test:function test(e){return "bada"===e.getBrowserName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "windows phone"===e.getBrowserName();},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"};}},{test:function test(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return "android"===e.getOSName(!0)&&t>=3;},describe:function describe(){return {type:s.PLATFORMS_MAP.tablet};}},{test:function test(e){return "android"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.mobile};}},{test:function test(e){return "macos"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop,vendor:"Apple"};}},{test:function test(e){return "windows"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop};}},{test:function test(e){return "linux"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.desktop};}},{test:function test(e){return "playstation 4"===e.getOSName(!0);},describe:function describe(){return {type:s.PLATFORMS_MAP.tv};}},{test:function test(e){return "roku"===e.getOSName(!0);},describe:function describe(){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 test(e){return "microsoft edge"===e.getBrowserName(!0);},describe:function describe(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 describe(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 test(e){return e.test(/presto/i);},describe:function describe(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 test(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r;},describe:function describe(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 describe(){return {name:s.ENGINE_MAP.Blink};}},{test:[/(apple)?webkit/i],describe:function describe(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;}});});})(es5);var Bowser=/*@__PURE__*/getDefaultExportFromCjs(es5.exports);function getBrowserDetails(){var browser=Bowser.getParser(window.navigator.userAgent);return browser.getBrowser();}/**
|
|
5329
3819
|
* Creates a continuation function with some arguments already applied.
|
|
5330
3820
|
*
|
|
5331
3821
|
* Useful as a shorthand when combined with other control flow functions. Any
|
|
@@ -5432,7 +3922,7 @@ function awaitify(asyncFn){var arity=arguments.length>1&&arguments[1]!==undefine
|
|
|
5432
3922
|
var breakLoop={};function once(fn){function wrapper(){if(fn===null)return;var callFn=fn;fn=null;for(var _len8=arguments.length,args=new Array(_len8),_key8=0;_key8<_len8;_key8++){args[_key8]=arguments[_key8];}callFn.apply(this,args);}Object.assign(wrapper,fn);return wrapper;}function getIterator(coll){return coll[Symbol.iterator]&&coll[Symbol.iterator]();}function createArrayIterator(coll){var i=-1;var len=coll.length;return function next(){return ++i<len?{value:coll[i],key:i}:null;};}function createES2015Iterator(iterator){var i=-1;return function next(){var item=iterator.next();if(item.done)return null;i++;return {value:item.value,key:i};};}function createObjectIterator(obj){var okeys=obj?Object.keys(obj):[];var i=-1;var len=okeys.length;return function next(){var key=okeys[++i];if(key==='__proto__'){return next();}return i<len?{value:obj[key],key}:null;};}function createIterator(coll){if(isArrayLike(coll)){return createArrayIterator(coll);}var iterator=getIterator(coll);return iterator?createES2015Iterator(iterator):createObjectIterator(coll);}function onlyOnce(fn){return function(){if(fn===null)throw new Error("Callback was already called.");var callFn=fn;fn=null;for(var _len9=arguments.length,args=new Array(_len9),_key9=0;_key9<_len9;_key9++){args[_key9]=arguments[_key9];}callFn.apply(this,args);};}// for async generators
|
|
5433
3923
|
function asyncEachOfLimit(generator,limit,iteratee,callback){var done=false;var canceled=false;var awaiting=false;var running=0;var idx=0;function replenish(){//console.log('replenish')
|
|
5434
3924
|
if(running>=limit||awaiting||done)return;//console.log('replenish awaiting')
|
|
5435
|
-
awaiting=true;generator.next().then(
|
|
3925
|
+
awaiting=true;generator.next().then(_ref6=>{var{value,done:iterDone}=_ref6;//console.log('got value', value)
|
|
5436
3926
|
if(canceled||done)return;awaiting=false;if(iterDone){done=true;if(running<=0){//console.log('done nextCb')
|
|
5437
3927
|
callback(null);}return;}running++;iteratee(value,idx,iterateeCallback);idx++;replenish();}).catch(handleError);}function iterateeCallback(err,result){//console.log('iterateeCallback')
|
|
5438
3928
|
running-=1;if(canceled)return;if(err)return handleError(err);if(err===false){done=true;canceled=true;return;}if(result===breakLoop||done&&running<=0){done=true;//console.log('done iterCb')
|
|
@@ -7339,7 +5829,1535 @@ if(context.level===Logger.WARN&&console.warn){hdlr=console.warn;}else if(context
|
|
|
7339
5829
|
// `options` hash can be used to configure the default logLevel and provide a custom message formatter.
|
|
7340
5830
|
Logger.useDefaults=function(options){Logger.setLevel(options&&options.defaultLevel||Logger.DEBUG);Logger.setHandler(Logger.createDefaultHandler(options));};// Createa an alias to useDefaults to avoid reaking a react-hooks rule.
|
|
7341
5831
|
Logger.setDefaults=Logger.useDefaults;// Export to popular environments boilerplate.
|
|
7342
|
-
if(module.exports){module.exports=Logger;}else {Logger._prevLogger=global.Logger;Logger.noConflict=function(){global.Logger=Logger._prevLogger;return Logger;};global.Logger=Logger;}})(commonjsGlobal$3);})(logger$1);var Logger$3=logger$1.exports;var DEFAULT_LOGGER_NAME='web-client-media-engine';var logger$4=Logger$3.get(DEFAULT_LOGGER_NAME);logger$4.setLevel(Logger$3.DEBUG);function setLogHandler(logHandler){Logger$3.setHandler(logHandler);Logger$1.setHandler(logHandler);Logger$2.setHandler(logHandler);}function toMediaStreamTrackKind(mediaType){return [MediaType.VideoMain,MediaType.VideoSlides].includes(mediaType)?exports.MediaStreamTrackKind.Video:exports.MediaStreamTrackKind.Audio;}function webRtcVideoContentHintToJmpVideoContentHint(hint){if(hint==='motion'){return 'motion';}if(hint==='detail'){return 'sharpness';}return undefined;}function toMediaFamily(kind){if(kind===exports.MediaStreamTrackKind.Video){return MediaFamily.Video;}return MediaFamily.Audio;}var MultistreamConnectionEventNames;(function(MultistreamConnectionEventNames){MultistreamConnectionEventNames["VideoSourceCountUpdate"]="video-source-count-update";MultistreamConnectionEventNames["AudioSourceCountUpdate"]="audio-source-count-update";MultistreamConnectionEventNames["ActiveSpeakerNotification"]="active-speaker-notification";MultistreamConnectionEventNames["ConnectionStateUpdate"]="connection-state-update";})(MultistreamConnectionEventNames||(MultistreamConnectionEventNames={}));var defaultMultistreamConnectionOptions={floorControlledPresentation:false,disableSimulcast:getBrowserDetails().name==='Firefox',streamSignalingMode:'SSRC',bundlePolicy:'max-compat',iceServers:undefined,disableContentSimulcast:true,enableMainAudio:true,enableMainVideo:true};class MultistreamConnection extends EventEmitter{constructor(){var userOptions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _a,_b;super();this.sendTransceivers=new Map();this.recvTransceivers=new Map();this.jmpSessions=new Map();this.pendingJmpTasks=[];this.metricsCallback=()=>{};this.overuseUpdateCallback=()=>{};this.customCodecParameters=new Map();this.midMap=new Map();this.currentMid=0;this.offerAnswerQueue=new AsyncQueue();this.options=Object.assign(Object.assign({},defaultMultistreamConnectionOptions),userOptions);logger$4.info("Creating multistream connection with options ".concat(JSON.stringify(this.options)));this.initializePeerConnection();this.streamSignalerManager=new StreamSignalerManager(this.options.streamSignalingMode);this.overuseStateManager=new OveruseStateManager(overuseState=>this.overuseUpdateCallback(overuseState));this.overuseStateManager.start();this.statsManager=new StatsManager(()=>this.pc.getStats(),stats=>this.preProcessStats(stats));var mainSceneId=generateSceneId();var videoMainEncodingOptions=this.getVideoEncodingOptions(MediaContent$1.Main);this.createSendTransceiver(MediaType.VideoMain,mainSceneId,videoMainEncodingOptions);this.createSendTransceiver(MediaType.AudioMain,mainSceneId);(_a=this.sendTransceivers.get(MediaType.VideoMain))===null||_a===void 0?void 0:_a.setActive(this.options.enableMainVideo);(_b=this.sendTransceivers.get(MediaType.AudioMain))===null||_b===void 0?void 0:_b.setActive(this.options.enableMainAudio);if(this.options.floorControlledPresentation){var videoPresentationEncodingOptions=this.getVideoEncodingOptions(MediaContent$1.Slides);var contentSceneId=generateSceneId();this.createSendTransceiver(MediaType.VideoSlides,contentSceneId,videoPresentationEncodingOptions);this.createSendTransceiver(MediaType.AudioSlides,contentSceneId);}}addMid(mediaType){var mid=this.currentMid++;var mids=this.midMap.get(mediaType)||[];mids.push("".concat(mid));this.midMap.set(mediaType,mids);}clearMids(){this.midMap=new Map();this.currentMid=0;}initializePeerConnection(){var _a;(_a=this.pc)===null||_a===void 0?void 0:_a.close();this.pc=new PeerConnection({iceServers:this.options.iceServers,bundlePolicy:this.options.bundlePolicy});this.pc.on(PeerConnection.Events.ConnectionStateChange,state=>this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate,state));this.attachMetricsObserver();this.createDataChannel();}getConnectionState(){return this.pc.getConnectionState();}getVideoEncodingOptions(content){var enabledSimulcast=content===MediaContent$1.Main?!this.options.disableSimulcast:!this.options.disableContentSimulcast;return enabledSimulcast?[{scaleResolutionDownBy:4,active:false},{scaleResolutionDownBy:2,active:false},{active:false}]:[{active:false}];}createSendTransceiver(mediaType,sceneId,sendEncodingsOptions){var rtcTransceiver;try{rtcTransceiver=this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'sendrecv',sendEncodings:sendEncodingsOptions});}catch(e){logger$4.error("addTransceiver failed due to : ".concat(e));throw e;}this.addMid(mediaType);var csi=generateCsi(getMediaFamily$1(mediaType),sceneId);this.sendTransceivers.set(mediaType,new SendOnlyTransceiver(rtcTransceiver,csi));this.createJmpSession(mediaType);}createJmpSession(mediaType){var jmpSession=new JmpSession(getMediaFamily$1(mediaType),getMediaContent(mediaType));jmpSession.setTxCallback(msg=>{var _a;if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)!=='open'){logger$4.error("DataChannel not created or not connected. Unable to send JMP message.");return;}logger$4.info("Sending JMP message: ".concat(msg));this.dataChannel.send(msg);});var prevNumTotalSources=0;var prevNumLiveSources=0;jmpSession.on(JmpSessionEvents$1.SourceAdvertisementReceived,data=>{if(data.numTotalSources!==prevNumTotalSources||data.numLiveSources!==prevNumLiveSources){prevNumTotalSources=data.numTotalSources;prevNumLiveSources=data.numLiveSources;var eventName=getMediaFamily$1(mediaType)===MediaFamily.Video?MultistreamConnectionEventNames.VideoSourceCountUpdate:MultistreamConnectionEventNames.AudioSourceCountUpdate;this.emit(eventName,data.numTotalSources,data.numLiveSources,getMediaContent(mediaType));}});jmpSession.on(JmpSessionEvents$1.MediaRequestStatusReceived,data=>{data.streamStates.forEach(s=>{var receiveSlot=this.getReceiveSlotById(s.id);if(!receiveSlot){logger$4.warn("Got MediaRequestStatus for unknown receive slot: ".concat(s.id));return;}receiveSlot._updateSource(s.state,s.csi);});});jmpSession.on(JmpSessionEvents$1.MediaRequestReceived,data=>{if(getMediaFamily$1(mediaType)===MediaFamily.Video){this.sendMediaRequestStatus(mediaType);}this.updateRequestedStreams(mediaType,data.requests);});jmpSession.on(JmpSessionEvents$1.ActiveSpeaker,data=>this.emit(MultistreamConnectionEventNames.ActiveSpeakerNotification,data));this.jmpSessions.set(mediaType,jmpSession);}updateRequestedStreams(mediaType,requests){var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);var signaler=this.streamSignalerManager.getEgressStreamSignalerOrThrow(sendTransceiver.mid);var mediaFamily=getMediaFamily$1(mediaType);var requestedIdEncodingParamsMap=new Map();var rsRequests=requests.filter(r=>isValidReceiverSelectedInfo(r.policySpecificInfo));if(rsRequests.length!==requests.length){logger$4.warn('Ignoring non-receiver-selected requests');}rsRequests.forEach(_ref6=>{var{ids,policySpecificInfo,codecInfos,maxPayloadBitsPerSecond}=_ref6;var _a,_b,_c,_d;if(ids.length>1){throw new Error("More than a single ID being unexpected/invalid ".concat(ids));}if(ids.length===0){return;}if(sendTransceiver.csi!==policySpecificInfo.csi){logger$4.warn('csi in the StreamRequest does not match');return;}var id=ids[0];var codecInfo=codecInfos[0];var streamIdsMatched=signaler.getSenderIds().some(validId=>compareStreamIds(id,validId));if(streamIdsMatched){var encodingIndex=signaler.getEncodingIndexForStreamId(id);if(encodingIndex!==-1){var encodingParams={maxPayloadBitsPerSecond};if(mediaFamily===MediaFamily.Video){var trackSettings=(_a=sendTransceiver.publishedTrack)===null||_a===void 0?void 0:_a.getSettings();if(trackSettings){encodingParams.scaleDownRatio=getScaleDownRatio(trackSettings.width,trackSettings.height,(_b=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_b===void 0?void 0:_b.maxFs,(_c=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_c===void 0?void 0:_c.maxWidth,(_d=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_d===void 0?void 0:_d.maxHeight);}}requestedIdEncodingParamsMap.set(encodingIndex,encodingParams);}else {logger$4.warn("".concat(mediaType,": Unable to get encoding index for stream ID: ").concat(JSON.stringify(id)));}}else {logger$4.warn("".concat(mediaType,": Unable to find matching stream ID for requested ID: ").concat(JSON.stringify(id)));}});sendTransceiver.setTrackRequested(requestedIdEncodingParamsMap.size>0);sendTransceiver.updateSendParameters(requestedIdEncodingParamsMap);}createDataChannel(){var dataChannel=this.pc.createDataChannel('datachannel',{});dataChannel.onopen=e=>{logger$4.info('DataChannel opened: ',e);[...this.sendTransceivers.keys()].forEach(mediaType=>{this.sendSourceAdvertisement(mediaType);});logger$4.info("Flushing pending JMP task queue");this.pendingJmpTasks.forEach(t=>t());this.pendingJmpTasks=[];};dataChannel.onmessage=e=>{var parsed;try{parsed=JSON.parse(e.data);}catch(err){logger$4.error("Error parsing datachannel JSON: ".concat(err));return;}logger$4.debug('DataChannel got msg: ',parsed);var homerMsg=HomerMsg.fromJson(parsed);if(!homerMsg){logger$4.error("Received invalid datachannel message: ".concat(e));return;}var jmpMsg=homerMsg.payload;if(!isValidJmpMsg(jmpMsg)){logger$4.error("Received invalid JMP msg: ".concat(jmpMsg));return;}var mediaType=getMediaType(jmpMsg.mediaFamily,jmpMsg.mediaContent);var jmpSession=this.jmpSessions.get(mediaType);if(!jmpSession){logger$4.error("Unable to find JMP session for media type ".concat(mediaType,"."));return;}jmpSession.receive(jmpMsg);};dataChannel.onclose=e=>{logger$4.info('DataChannel closed: ',e);};dataChannel.onerror=e=>{logger$4.info('DataChannel error: ',e);};this.dataChannel=dataChannel;}close(){this.sendTransceivers.forEach(t=>t.close());this.recvTransceivers.forEach(recvTransceivers=>{recvTransceivers.forEach(t=>t.close());});this.pc.close();}sendMediaRequestStatus(mediaType){var _a;if(getMediaFamily$1(mediaType)!==MediaFamily.Video){return;}var streamStates=this.getVideoStreamStates(mediaType);if(streamStates===null){logger$4.debug("Empty streamStates, not sending MediaRequestStatus");return;}var task=()=>{var _a;(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendMediaRequestStatus(streamStates);};if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}sendSourceAdvertisement(mediaType){var _a,_b;var transceiver=this.getSendTransceiverOrThrow(mediaType);var numLiveSources=((_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.muted)===false?1:0;var task;if(getMediaFamily$1(mediaType)===MediaFamily.Video){var sources=this.getVideoStreamStates(mediaType);if(sources===null){return;}var contentHint;if(transceiver.publishedTrack instanceof LocalDisplayTrack){contentHint=transceiver.publishedTrack.videoContentHint;}task=()=>{var _a;(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendSourceAdvertisement(1,numLiveSources,[],webRtcVideoContentHintToJmpVideoContentHint(contentHint));};}else {task=()=>{var _a;return (_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendSourceAdvertisement(1,numLiveSources);};}if(((_b=this.dataChannel)===null||_b===void 0?void 0:_b.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}publishTrack(track){return __awaiter(this,void 0,void 0,function*(){var mediaContent;if((track instanceof LocalDisplayTrack||track instanceof LocalSystemAudioTrack)&&this.options.floorControlledPresentation){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}var mediaFamily=toMediaFamily(track.kind);var mediaType=getMediaType(mediaFamily,mediaContent);var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);if(track===sendTransceiver.publishedTrack){logger$4.warn("This track has already been published on the transceiver.");return Promise.resolve();}this.addTrackListeners(mediaType,track);return sendTransceiver.publishTrack(track);});}unpublishTrack(track){return __awaiter(this,void 0,void 0,function*(){var mediaContent;if((track instanceof LocalDisplayTrack||track instanceof LocalSystemAudioTrack)&&this.options.floorControlledPresentation){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}var mediaFamily=toMediaFamily(track.kind);var mediaType=getMediaType(mediaFamily,mediaContent);var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);return sendTransceiver.unpublishTrack();});}addTrackListeners(mediaType,track){var onTrackResolutionChange=()=>{this.sendMediaRequestStatus(mediaType);};track.on(LocalTrack.Events.TrackConstraintsChange,onTrackResolutionChange);var onTrackMute=()=>{this.sendSourceAdvertisement(mediaType);this.sendMediaRequestStatus(mediaType);};track.on(LocalTrack.Events.Muted,onTrackMute);var onTrackPublish=event=>{if(!event.isPublished){track.off(LocalTrack.Events.Muted,onTrackMute);track.off(LocalTrack.Events.PublishedStateUpdate,onTrackPublish);track.off(LocalTrack.Events.TrackConstraintsChange,onTrackResolutionChange);}if(!track.muted){this.sendSourceAdvertisement(mediaType);this.sendMediaRequestStatus(mediaType);}};track.on(LocalTrack.Events.PublishedStateUpdate,onTrackPublish);}getVideoStreamStates(mediaType){var _a,_b,_c;var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);var signaler=this.streamSignalerManager.getEgressStreamSignaler(sendTransceiver.mid);if(!signaler){return null;}var activeSimulcastLayerNumber=((_a=sendTransceiver.publishedTrack)===null||_a===void 0?void 0:_a.getNumActiveSimulcastLayers())||0;var published=(_b=sendTransceiver.publishedTrack)===null||_b===void 0?void 0:_b.published;var muted=((_c=sendTransceiver.publishedTrack)===null||_c===void 0?void 0:_c.muted)===true;return signaler.getSenderIds().map(id=>{var state;if(!published){state='no source';}else if(muted){state='avatar';}else if(activeSimulcastLayerNumber<signaler.getEncodingIndexForStreamId(id)){state='no source';}else {state='live';}return {id,state,csi:sendTransceiver.csi};});}createReceiveSlot(mediaType){return __awaiter(this,void 0,void 0,function*(){return new Promise(createReceiveSlotResolve=>{this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){var rtcRtpTransceiver=this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'recvonly'});this.addMid(mediaType);var recvOnlyTransceiver=new ReceiveOnlyTransceiver(rtcRtpTransceiver,mid=>{var ingressSignaler=this.streamSignalerManager.getIngressStreamSignaler(mid);if(!ingressSignaler){return null;}return ingressSignaler.getReceiverId();});if(this.pc.getRemoteDescription()){yield this.doLocalOfferAnswer();}this.recvTransceivers.set(mediaType,[...(this.recvTransceivers.get(mediaType)||[]),recvOnlyTransceiver]);createReceiveSlotResolve(recvOnlyTransceiver.receiveSlot);}));});});}getIngressPayloadType(mediaType,mimeType){var _a,_b,_c;var requestedMediaCodecType=mimeType.split('/')[1];var requestedMid=(_a=this.sendTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.mid;var parsedOffer=parse((_b=this.pc.getLocalDescription())===null||_b===void 0?void 0:_b.sdp);var parsedAnswer=parse((_c=this.pc.getRemoteDescription())===null||_c===void 0?void 0:_c.sdp);var senderCodecs=parsedAnswer.avMedia.filter(media=>requestedMid===media.mid).map(media=>[...media.codecs.values()]).flat().filter(ci=>ci.name===requestedMediaCodecType);var receiverCodecs=parsedOffer.avMedia.filter(media=>requestedMid===media.mid).map(media=>[...media.codecs.values()]).flat().filter(ci=>ci.name===requestedMediaCodecType);if(!senderCodecs||!receiverCodecs||senderCodecs.length===0||receiverCodecs.length===0){throw new Error("sender codecs or receiver codecs is undefined or empty");}var senderCodec=senderCodecs[0];var targetCodec=receiverCodecs.find(receiverCodec=>{return areCodecsCompatible(senderCodec,receiverCodec);});if(!targetCodec||!targetCodec.pt){throw new Error("ingress payload type is not well defined in receiver codecs");}return targetCodec.pt;}createOffer(){return __awaiter(this,void 0,void 0,function*(){if(!this.pc.getLocalDescription()){this.currentMid++;}return new Promise(createOfferResolve=>{this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){var _a;if(this.setAnswerResolve!==undefined){throw new Error("Tried to start a new createOffer flow before the old one had finished");}var setAnswerPromise=new Promise(resolve=>{this.setAnswerResolve=resolve;});var offer=yield this.pc.createOffer();if(!offer.sdp){throw new Error('No SDP offer');}offer.sdp=this.preProcessLocalOffer(offer.sdp);yield this.pc.setLocalDescription(offer);var sdpToSend=this.prepareLocalOfferForRemoteServer((_a=this.pc.getLocalDescription())===null||_a===void 0?void 0:_a.sdp);createOfferResolve({type:'offer',sdp:sdpToSend});yield setAnswerPromise;}));});});}setAnswer(answer){return __awaiter(this,void 0,void 0,function*(){var isInitialAnswer=!this.pc.getRemoteDescription();var sdp=this.preProcessRemoteAnswer(answer);if(!this.setAnswerResolve){throw new Error("Call to setAnswer without having previously called createOffer");}return this.pc.setRemoteDescription({type:'answer',sdp}).then(()=>__awaiter(this,void 0,void 0,function*(){if(this.setAnswerResolve){this.setAnswerResolve();this.setAnswerResolve=undefined;}else {logger$4.debug("setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription");}if(isInitialAnswer&&this.customCodecParameters.size>0){yield this.queueLocalOfferAnswer();}}));});}doLocalOfferAnswer(){var _a;return __awaiter(this,void 0,void 0,function*(){var offer=yield this.pc.createOffer();if(!offer.sdp){throw new Error('No SDP offer');}offer.sdp=this.preProcessLocalOffer(offer.sdp);yield this.pc.setLocalDescription(offer);var answer=this.preProcessRemoteAnswer((_a=this.pc.getRemoteDescription())===null||_a===void 0?void 0:_a.sdp);return this.pc.setRemoteDescription({type:'answer',sdp:answer});});}queueLocalOfferAnswer(){return __awaiter(this,void 0,void 0,function*(){return this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){yield this.doLocalOfferAnswer();}));});}enableMultistreamAudio(enabled){var sendTransceiver=this.sendTransceivers.get(MediaType.AudioMain);if(sendTransceiver){return sendTransceiver.setActive(enabled);}return false;}preProcessLocalOffer(offer){var parsed=parse(offer);filterCodecs(parsed,['h264','opus','rtx']);setMaxBandwidth(parsed,20000000);parsed.avMedia.filter(av=>av.direction==='recvonly').forEach(av=>{var ingressSignaler=this.streamSignalerManager.getOrCreateIngressStreamSignaler(av.mid);ingressSignaler.signalLocalStreams(av);});parsed.avMedia.filter(av=>av.direction==='sendrecv').forEach(av=>{var egressSignaler=this.streamSignalerManager.getOrCreateEgressStreamSignaler(av.mid);var simulcastEnabled=hasSimulcast(av);var rtxEnabled=av.type==='video';egressSignaler.signalStreams(simulcastEnabled,rtxEnabled,av);if(av.type==='video'){[...av.codecs.values()].filter(ci=>ci.name==='H264').forEach(ci=>{ci.fmtParams.set('max-mbps',"".concat(defaultMaxVideoEncodeMbps));ci.fmtParams.set('max-fs',"".concat(defaultMaxVideoEncodeFrameSize));});}var mediaType=[...this.sendTransceivers.keys()].find(key=>{var _a;return ((_a=this.sendTransceivers.get(key))===null||_a===void 0?void 0:_a.mid)===av.mid;});if(mediaType&&this.customCodecParameters.has(mediaType)){[...av.codecs.values()].filter(ci=>ci.name===(av.type==='audio'?'opus':'H264')).forEach(ci=>{var _a;(_a=this.customCodecParameters.get(mediaType))===null||_a===void 0?void 0:_a.forEach((value,param)=>{if(value===null){ci.fmtParams.delete(param);}else {ci.fmtParams.set(param,"".concat(value));}});});}});if(getBrowserDetails().name!=='Firefox'){setupBundle(parsed,this.options.bundlePolicy,this.midMap);}return parsed.toString();}prepareLocalOfferForRemoteServer(offer){var parsed=parse(offer);var midContentMap=new Map();this.sendTransceivers.forEach((transceiver,mediaType)=>{midContentMap.set(transceiver.mid,getMediaContent(mediaType));});injectContentTypes(parsed,midContentMap);var csiMap=new Map();this.sendTransceivers.forEach((transceiver,mediaType)=>{csiMap.set(mediaType,transceiver.csi);});injectJmpAttributes(parsed,csiMap,this.options.streamSignalingMode);filterRecvOnlyMlines(parsed);injectDummyCandidates(parsed);parsed.avMedia.filter(av=>av.direction==='sendrecv'&&av.type==='video').forEach(av=>{var ssrcGroup=av.ssrcGroups.find(sg=>sg.semantics==='SIM');if(ssrcGroup){ssrcGroup.ssrcs.forEach((ssrc,index)=>{av.addLine(new SsrcLine(ssrc,'fmtp',"* max-fs=".concat(simulcastMaxFrameSizes[index])));});}});if(getBrowserDetails().name==='Firefox'){setupBundle(parsed,this.options.bundlePolicy,this.midMap);if(this.options.bundlePolicy==='max-bundle'){parsed.media.forEach((mline,index)=>{if(index>0){mline.port=parsed.media[0].port;}});}}return parsed.toString();}preProcessRemoteAnswer(answer){var _a;var parsedAnswer=parse(answer);var parsedOffer=parse((_a=this.pc.getLocalDescription())===null||_a===void 0?void 0:_a.sdp);matchMlinesInAnswer(parsedOffer,parsedAnswer,this.streamSignalerManager);if(getBrowserDetails().name==='Firefox'){setupBundle(parsedAnswer,this.options.bundlePolicy,this.midMap);if(this.options.bundlePolicy==='max-bundle'){var{ufrag,pwd}=parsedAnswer.media[0].iceInfo;parsedAnswer.media.forEach((mline,index)=>{if(index>0){mline.iceInfo.ufrag=ufrag;mline.iceInfo.pwd=pwd;}});}}return parsedAnswer.toString();}getSendTransceiverOrThrow(mediaType){var sendTransceiver=this.sendTransceivers.get(mediaType);if(!sendTransceiver){throw new Error("Unable to find matching transceiver for media type ".concat(mediaType));}return sendTransceiver;}getPublishedTracks(){return [...this.sendTransceivers.values()].map(transceiver=>transceiver.publishedTrack).filter(Boolean);}setCodecParameters(mediaType,parameters){return __awaiter(this,void 0,void 0,function*(){var currentParams=this.customCodecParameters.get(mediaType)||new Map();Object.entries(parameters).forEach(_ref7=>{var[param,value]=_ref7;currentParams.set(param,value);});this.customCodecParameters.set(mediaType,currentParams);if(this.pc.getRemoteDescription()){yield this.queueLocalOfferAnswer();}});}deleteCodecParameters(mediaType,parameters){return __awaiter(this,void 0,void 0,function*(){var currentParams=this.customCodecParameters.get(mediaType)||new Map();parameters.forEach(param=>{currentParams.set(param,null);});this.customCodecParameters.set(mediaType,currentParams);if(this.pc.getRemoteDescription()){yield this.queueLocalOfferAnswer();}});}requestMedia(mediaType,streamRequests){var _a;var task=()=>{var _a;var jmpSession=this.jmpSessions.get(mediaType);if(!jmpSession){logger$4.error("Unable to find jmp session for ".concat(mediaType));return;}var requestedReceiveSlotIds=[];streamRequests.forEach(sr=>{sr.receiveSlots.forEach(rs=>{if(!rs.id){logger$4.error("Running stream request task, but ReceiveSlot ID is missing!");return;}requestedReceiveSlotIds.push(rs.id);});});(_a=this.recvTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.forEach(transceiver=>{if(!requestedReceiveSlotIds.some(id=>compareStreamIds(id,transceiver.receiveSlot.id))){transceiver.receiveSlot._updateSource('no source',undefined);}});jmpSession.sendRequests(streamRequests.map(sr=>sr._toJmpStreamRequest()));};if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}renewPeerConnection(userOptions){if(userOptions){this.options=Object.assign(Object.assign({},this.options),userOptions);}logger$4.info("Renewing multistream connection with options ".concat(JSON.stringify(this.options)));this.clearMids();this.initializePeerConnection();this.streamSignalerManager=new StreamSignalerManager(this.options.streamSignalingMode);var mainSceneId=generateSceneId();var slidesSceneId=generateSceneId();this.sendTransceivers.forEach((transceiver,mediaType)=>{var _a;var mediaContent=getMediaContent(mediaType);var sceneId=mediaContent===MediaContent$1.Main?mainSceneId:slidesSceneId;this.addMid(mediaType);transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'sendrecv',sendEncodings:getMediaFamily$1(mediaType)===MediaFamily.Video?this.getVideoEncodingOptions(mediaContent):undefined}));transceiver.csi=generateCsi(getMediaFamily$1(mediaType),sceneId);(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.close();this.createJmpSession(mediaType);});this.recvTransceivers.forEach((transceivers,mediaType)=>{transceivers.forEach(t=>{this.addMid(mediaType);t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'recvonly'}));});});}getReceiveSlotById(id){return [...this.recvTransceivers.values()].flat().map(transceiver=>transceiver.receiveSlot).find(receiveSlot=>{var receiveSlotId=receiveSlot.id||{};return Object.keys(receiveSlotId).length===Object.keys(id).length&&Object.keys(receiveSlotId).every(key=>Object.prototype.hasOwnProperty.call(id,key)&&receiveSlotId[key]===id[key]);});}getStats(){return this.statsManager.getStats();}getTransceiverStats(){return __awaiter(this,void 0,void 0,function*(){return organizeTransceiverStats(this.sendTransceivers,this.recvTransceivers);});}preProcessStats(stats){return __awaiter(this,void 0,void 0,function*(){yield Promise.all([...this.sendTransceivers.entries()].map(_ref8=>{var[mediaType,transceiver]=_ref8;return __awaiter(this,void 0,void 0,function*(){(yield transceiver.getStats()).forEach(senderStats=>{var _a;if(senderStats.type==='outbound-rtp'){var statsToModify=stats.get(senderStats.id);statsToModify.mid=transceiver.mid;statsToModify.csi=transceiver.csi;statsToModify.mediaType=mediaType;var trackSettings=(_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack.getSettings();if(trackSettings===null||trackSettings===void 0?void 0:trackSettings.frameRate){statsToModify.targetFrameRate=trackSettings===null||trackSettings===void 0?void 0:trackSettings.frameRate;}stats.set(senderStats.id,statsToModify);}});});}));yield Promise.all([...this.recvTransceivers.entries()].map(_ref9=>{var[mediaType,transceivers]=_ref9;return __awaiter(this,void 0,void 0,function*(){yield Promise.all(transceivers.map(transceiver=>__awaiter(this,void 0,void 0,function*(){(yield transceiver.getStats()).forEach(receiverStats=>{var _a;if(receiverStats.type==='inbound-rtp'){var statsToModify=stats.get(receiverStats.id);statsToModify.mid=(_a=transceiver.receiveSlot.id)===null||_a===void 0?void 0:_a.mid;statsToModify.csi=transceiver.receiveSlot.currentRxCsi;statsToModify.mediaType=mediaType;var signaler=this.streamSignalerManager.getIngressStreamSignaler(statsToModify.mid);if(signaler){Object.assign(statsToModify,signaler.getReceiverId());}stats.set(receiverStats.id,statsToModify);}});})));});}));});}attachMetricsObserver(){rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(),data=>this.metricsCallback(data),5000);}setMetricsCallback(callback){this.metricsCallback=callback;}setOveruseUpdateCallback(callback){this.overuseUpdateCallback=callback;}getCsiByMediaType(mediaType){var _a;return (_a=this.sendTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.csi;}getAllCsis(){return {audioMain:this.getCsiByMediaType(MediaType.AudioMain),audioSlides:this.getCsiByMediaType(MediaType.AudioSlides),videoMain:this.getCsiByMediaType(MediaType.VideoMain),videoSlides:this.getCsiByMediaType(MediaType.VideoSlides)};}}class StreamRequest{constructor(policy,policySpecificInfo,receiveSlots,maxPayloadBitsPerSecond){var codecInfos=arguments.length>4&&arguments[4]!==undefined?arguments[4]:[];this.policy=policy;this.policySpecificInfo=policySpecificInfo;this.receiveSlots=receiveSlots;this.maxPayloadBitsPerSecond=maxPayloadBitsPerSecond;this.codecInfos=codecInfos;}_toJmpStreamRequest(){return new StreamRequest$1(this.policy,this.policySpecificInfo,this.receiveSlots.map(rs=>rs.id),this.maxPayloadBitsPerSecond,this.codecInfos);}}
|
|
5832
|
+
if(module.exports){module.exports=Logger;}else {Logger._prevLogger=global.Logger;Logger.noConflict=function(){global.Logger=Logger._prevLogger;return Logger;};global.Logger=Logger;}})(commonjsGlobal$3);})(logger$1);var Logger$3=logger$1.exports;var DEFAULT_LOGGER_NAME='web-client-media-engine';var logger$4=Logger$3.get(DEFAULT_LOGGER_NAME);logger$4.setLevel(Logger$3.DEBUG);function setLogHandler(logHandler){Logger$3.setHandler(logHandler);Logger$1.setHandler(logHandler);Logger$2.setHandler(logHandler);}function toMediaStreamTrackKind(mediaType){return [MediaType.VideoMain,MediaType.VideoSlides].includes(mediaType)?exports.MediaStreamTrackKind.Video:exports.MediaStreamTrackKind.Audio;}function webRtcVideoContentHintToJmpVideoContentHint(hint){if(hint==='motion'){return 'motion';}if(hint==='detail'){return 'sharpness';}return undefined;}function createEgressStreamSignaler(signalingMode,mid){if(signalingMode==='MID-RID'){return new RidEgressStreamSignaler(mid);}if(signalingMode==='SSRC'){return new SsrcEgressStreamSignaler();}throw new Error("unknown signaling mode");}function createIngressStreamSignaler(signalingMode,mid){if(signalingMode==='MID-RID'){return new RidIngressStreamSignaler(mid);}if(signalingMode==='SSRC'){return new SsrcIngressStreamSignaler();}throw new Error("unknown signaling mode");}function toMediaFamily(kind){if(kind===exports.MediaStreamTrackKind.Video){return MediaFamily.Video;}return MediaFamily.Audio;}var MultistreamConnectionEventNames;(function(MultistreamConnectionEventNames){MultistreamConnectionEventNames["VideoSourceCountUpdate"]="video-source-count-update";MultistreamConnectionEventNames["AudioSourceCountUpdate"]="audio-source-count-update";MultistreamConnectionEventNames["ActiveSpeakerNotification"]="active-speaker-notification";MultistreamConnectionEventNames["ConnectionStateUpdate"]="connection-state-update";})(MultistreamConnectionEventNames||(MultistreamConnectionEventNames={}));var defaultMultistreamConnectionOptions={floorControlledPresentation:false,disableSimulcast:getBrowserDetails().name==='Firefox',streamSignalingMode:'SSRC',bundlePolicy:'max-compat',iceServers:undefined,disableContentSimulcast:true,enableMainAudio:true,enableMainVideo:true};class MultistreamConnection extends EventEmitter{constructor(){var userOptions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var _a,_b;super();this.sendTransceivers=new Map();this.recvTransceivers=new Map();this.jmpSessions=new Map();this.pendingJmpTasks=[];this.metricsCallback=()=>{};this.overuseUpdateCallback=()=>{};this.midPredictor=new MidPredictor();this.offerAnswerQueue=new AsyncQueue();this.options=Object.assign(Object.assign({},defaultMultistreamConnectionOptions),userOptions);logger$4.info("Creating multistream connection with options ".concat(JSON.stringify(this.options)));this.initializePeerConnection();this.overuseStateManager=new OveruseStateManager(overuseState=>this.overuseUpdateCallback(overuseState));this.overuseStateManager.start();this.statsManager=new StatsManager(()=>this.pc.getStats(),stats=>this.preProcessStats(stats));var mainSceneId=generateSceneId();var videoMainEncodingOptions=this.getVideoEncodingOptions(MediaContent$1.Main);this.createSendTransceiver(MediaType.VideoMain,mainSceneId,videoMainEncodingOptions);this.createSendTransceiver(MediaType.AudioMain,mainSceneId);(_a=this.sendTransceivers.get(MediaType.VideoMain))===null||_a===void 0?void 0:_a.setActive(this.options.enableMainVideo);(_b=this.sendTransceivers.get(MediaType.AudioMain))===null||_b===void 0?void 0:_b.setActive(this.options.enableMainAudio);if(this.options.floorControlledPresentation){var videoPresentationEncodingOptions=this.getVideoEncodingOptions(MediaContent$1.Slides);var contentSceneId=generateSceneId();this.createSendTransceiver(MediaType.VideoSlides,contentSceneId,videoPresentationEncodingOptions);this.createSendTransceiver(MediaType.AudioSlides,contentSceneId);}}initializePeerConnection(){var _a;(_a=this.pc)===null||_a===void 0?void 0:_a.close();this.pc=new PeerConnection({iceServers:this.options.iceServers,bundlePolicy:this.options.bundlePolicy});this.pc.on(PeerConnection.Events.ConnectionStateChange,state=>this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate,state));this.attachMetricsObserver();this.createDataChannel();}getConnectionState(){return this.pc.getConnectionState();}getVideoEncodingOptions(content){var enabledSimulcast=content===MediaContent$1.Main?!this.options.disableSimulcast:!this.options.disableContentSimulcast;return enabledSimulcast?[{scaleResolutionDownBy:4,active:false},{scaleResolutionDownBy:2,active:false},{active:false}]:[{active:false}];}createSendTransceiver(mediaType,sceneId,sendEncodingsOptions){var rtcTransceiver;try{rtcTransceiver=this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'sendrecv',sendEncodings:sendEncodingsOptions});}catch(e){logger$4.error("addTransceiver failed due to : ".concat(e));throw e;}var mid=this.midPredictor.getNextMid(mediaType);var csi=generateCsi(getMediaFamily$1(mediaType),sceneId);var signaler=createEgressStreamSignaler(this.options.streamSignalingMode,mid);var transceiver=new SendOnlyTransceiver(rtcTransceiver,mid,csi,signaler);if(getMediaFamily$1(mediaType)===MediaFamily.Video){transceiver.rtxEnabled=true;transceiver.setCodecParameters({'max-mbps':"".concat(defaultMaxVideoEncodeMbps),'max-fs':"".concat(defaultMaxVideoEncodeFrameSize)});}this.sendTransceivers.set(mediaType,transceiver);this.createJmpSession(mediaType);}createJmpSession(mediaType){var jmpSession=new JmpSession(getMediaFamily$1(mediaType),getMediaContent(mediaType));jmpSession.setTxCallback(msg=>{var _a;if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)!=='open'){logger$4.error("DataChannel not created or not connected. Unable to send JMP message.");return;}logger$4.info("Sending JMP message: ".concat(msg));this.dataChannel.send(msg);});var prevNumTotalSources=0;var prevNumLiveSources=0;jmpSession.on(JmpSessionEvents$1.SourceAdvertisementReceived,data=>{if(data.numTotalSources!==prevNumTotalSources||data.numLiveSources!==prevNumLiveSources){prevNumTotalSources=data.numTotalSources;prevNumLiveSources=data.numLiveSources;var eventName=getMediaFamily$1(mediaType)===MediaFamily.Video?MultistreamConnectionEventNames.VideoSourceCountUpdate:MultistreamConnectionEventNames.AudioSourceCountUpdate;this.emit(eventName,data.numTotalSources,data.numLiveSources,getMediaContent(mediaType));}});jmpSession.on(JmpSessionEvents$1.MediaRequestStatusReceived,data=>{data.streamStates.forEach(s=>{var receiveSlot=this.getReceiveSlotById(s.id);if(!receiveSlot){logger$4.warn("Got MediaRequestStatus for unknown receive slot: ".concat(s.id));return;}receiveSlot._updateSource(s.state,s.csi);});});jmpSession.on(JmpSessionEvents$1.MediaRequestReceived,data=>{if(getMediaFamily$1(mediaType)===MediaFamily.Video){this.sendMediaRequestStatus(mediaType);}this.updateRequestedStreams(mediaType,data.requests);});jmpSession.on(JmpSessionEvents$1.ActiveSpeaker,data=>this.emit(MultistreamConnectionEventNames.ActiveSpeakerNotification,data));this.jmpSessions.set(mediaType,jmpSession);}updateRequestedStreams(mediaType,requests){var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);var mediaFamily=getMediaFamily$1(mediaType);var requestedIdEncodingParamsMap=new Map();var rsRequests=requests.filter(r=>isValidReceiverSelectedInfo(r.policySpecificInfo));if(rsRequests.length!==requests.length){logger$4.warn('Ignoring non-receiver-selected requests');}rsRequests.forEach(_ref7=>{var{ids,policySpecificInfo,codecInfos,maxPayloadBitsPerSecond}=_ref7;var _a,_b,_c,_d;if(ids.length>1){throw new Error("More than a single ID being unexpected/invalid ".concat(ids));}if(ids.length===0){return;}if(sendTransceiver.csi!==policySpecificInfo.csi){logger$4.warn('csi in the StreamRequest does not match');return;}var id=ids[0];var codecInfo=codecInfos[0];var streamIdsMatched=sendTransceiver.senderIds.some(validId=>compareStreamIds(id,validId));if(streamIdsMatched){var encodingIndex=sendTransceiver.getEncodingIndexForStreamId(id);if(encodingIndex!==-1){var encodingParams={maxPayloadBitsPerSecond};if(mediaFamily===MediaFamily.Video){var trackSettings=(_a=sendTransceiver.publishedTrack)===null||_a===void 0?void 0:_a.getSettings();if(trackSettings){encodingParams.scaleDownRatio=getScaleDownRatio(trackSettings.width,trackSettings.height,(_b=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_b===void 0?void 0:_b.maxFs,(_c=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_c===void 0?void 0:_c.maxWidth,(_d=codecInfo===null||codecInfo===void 0?void 0:codecInfo.h264)===null||_d===void 0?void 0:_d.maxHeight);}}requestedIdEncodingParamsMap.set(encodingIndex,encodingParams);}else {logger$4.warn("".concat(mediaType,": Unable to get encoding index for stream ID: ").concat(JSON.stringify(id)));}}else {logger$4.warn("".concat(mediaType,": Unable to find matching stream ID for requested ID: ").concat(JSON.stringify(id)));}});sendTransceiver.setTrackRequested(requestedIdEncodingParamsMap.size>0);sendTransceiver.updateSendParameters(requestedIdEncodingParamsMap);}createDataChannel(){var dataChannel=this.pc.createDataChannel('datachannel',{});dataChannel.onopen=e=>{logger$4.info('DataChannel opened: ',e);[...this.sendTransceivers.keys()].forEach(mediaType=>{this.sendSourceAdvertisement(mediaType);});logger$4.info("Flushing pending JMP task queue");this.pendingJmpTasks.forEach(t=>t());this.pendingJmpTasks=[];};dataChannel.onmessage=e=>{var parsed;try{parsed=JSON.parse(e.data);}catch(err){logger$4.error("Error parsing datachannel JSON: ".concat(err));return;}logger$4.debug('DataChannel got msg: ',parsed);var homerMsg=HomerMsg.fromJson(parsed);if(!homerMsg){logger$4.error("Received invalid datachannel message: ".concat(e));return;}var jmpMsg=homerMsg.payload;if(!isValidJmpMsg(jmpMsg)){logger$4.error("Received invalid JMP msg: ".concat(jmpMsg));return;}var mediaType=getMediaType(jmpMsg.mediaFamily,jmpMsg.mediaContent);var jmpSession=this.jmpSessions.get(mediaType);if(!jmpSession){logger$4.error("Unable to find JMP session for media type ".concat(mediaType,"."));return;}jmpSession.receive(jmpMsg);};dataChannel.onclose=e=>{logger$4.info('DataChannel closed: ',e);};dataChannel.onerror=e=>{logger$4.info('DataChannel error: ',e);};this.dataChannel=dataChannel;}close(){this.sendTransceivers.forEach(t=>t.close());this.recvTransceivers.forEach(recvTransceivers=>{recvTransceivers.forEach(t=>t.close());});this.pc.close();}sendMediaRequestStatus(mediaType){var _a;if(getMediaFamily$1(mediaType)!==MediaFamily.Video){return;}var streamStates=this.getVideoStreamStates(mediaType);var task=()=>{var _a;(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendMediaRequestStatus(streamStates);};if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}sendSourceAdvertisement(mediaType){var _a,_b;var transceiver=this.getSendTransceiverOrThrow(mediaType);var numLiveSources=((_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.muted)===false?1:0;var task;if(getMediaFamily$1(mediaType)===MediaFamily.Video){var sources=this.getVideoStreamStates(mediaType);if(sources===null){return;}var contentHint;if(transceiver.publishedTrack instanceof LocalDisplayTrack){contentHint=transceiver.publishedTrack.videoContentHint;}task=()=>{var _a;(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendSourceAdvertisement(1,numLiveSources,[],webRtcVideoContentHintToJmpVideoContentHint(contentHint));};}else {task=()=>{var _a;return (_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.sendSourceAdvertisement(1,numLiveSources);};}if(((_b=this.dataChannel)===null||_b===void 0?void 0:_b.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}publishTrack(track){return __awaiter(this,void 0,void 0,function*(){var mediaContent;if((track instanceof LocalDisplayTrack||track instanceof LocalSystemAudioTrack)&&this.options.floorControlledPresentation){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}var mediaFamily=toMediaFamily(track.kind);var mediaType=getMediaType(mediaFamily,mediaContent);var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);if(track===sendTransceiver.publishedTrack){logger$4.warn("This track has already been published on the transceiver.");return Promise.resolve();}this.addTrackListeners(mediaType,track);return sendTransceiver.publishTrack(track);});}unpublishTrack(track){return __awaiter(this,void 0,void 0,function*(){var mediaContent;if((track instanceof LocalDisplayTrack||track instanceof LocalSystemAudioTrack)&&this.options.floorControlledPresentation){mediaContent=MediaContent$1.Slides;}else {mediaContent=MediaContent$1.Main;}var mediaFamily=toMediaFamily(track.kind);var mediaType=getMediaType(mediaFamily,mediaContent);var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);return sendTransceiver.unpublishTrack();});}addTrackListeners(mediaType,track){var onTrackResolutionChange=()=>{this.sendMediaRequestStatus(mediaType);};track.on(LocalTrack.Events.TrackConstraintsChange,onTrackResolutionChange);var onTrackMute=()=>{this.sendSourceAdvertisement(mediaType);this.sendMediaRequestStatus(mediaType);};track.on(LocalTrack.Events.Muted,onTrackMute);var onTrackPublish=event=>{if(!event.isPublished){track.off(LocalTrack.Events.Muted,onTrackMute);track.off(LocalTrack.Events.PublishedStateUpdate,onTrackPublish);track.off(LocalTrack.Events.TrackConstraintsChange,onTrackResolutionChange);}if(!track.muted){this.sendSourceAdvertisement(mediaType);this.sendMediaRequestStatus(mediaType);}};track.on(LocalTrack.Events.PublishedStateUpdate,onTrackPublish);}getVideoStreamStates(mediaType){var _a,_b,_c;var sendTransceiver=this.getSendTransceiverOrThrow(mediaType);var activeSimulcastLayerNumber=((_a=sendTransceiver.publishedTrack)===null||_a===void 0?void 0:_a.getNumActiveSimulcastLayers())||0;var published=(_b=sendTransceiver.publishedTrack)===null||_b===void 0?void 0:_b.published;var muted=((_c=sendTransceiver.publishedTrack)===null||_c===void 0?void 0:_c.muted)===true;return sendTransceiver.senderIds.map(id=>{var state;if(!published){state='no source';}else if(muted){state='avatar';}else if(activeSimulcastLayerNumber<sendTransceiver.getEncodingIndexForStreamId(id)){state='no source';}else {state='live';}return {id,state,csi:sendTransceiver.csi};});}createReceiveSlot(mediaType){return __awaiter(this,void 0,void 0,function*(){return new Promise(createReceiveSlotResolve=>{this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){var rtcRtpTransceiver=this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'recvonly'});var transceiverMid=this.midPredictor.getNextMid(mediaType);var ingressSignaler=createIngressStreamSignaler(this.options.streamSignalingMode,transceiverMid);var recvOnlyTransceiver=new ReceiveOnlyTransceiver(rtcRtpTransceiver,transceiverMid,ingressSignaler);this.recvTransceivers.set(mediaType,[...(this.recvTransceivers.get(mediaType)||[]),recvOnlyTransceiver]);if(this.pc.getRemoteDescription()){yield this.doLocalOfferAnswer();}createReceiveSlotResolve(recvOnlyTransceiver.receiveSlot);}));});});}getIngressPayloadType(mediaType,mimeType){var _a,_b,_c;var requestedMediaCodecType=mimeType.split('/')[1];var requestedMid=(_a=this.sendTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.mid;var parsedOffer=parse$2((_b=this.pc.getLocalDescription())===null||_b===void 0?void 0:_b.sdp);var parsedAnswer=parse$2((_c=this.pc.getRemoteDescription())===null||_c===void 0?void 0:_c.sdp);var senderCodecs=parsedAnswer.avMedia.filter(media=>requestedMid===media.mid).map(media=>[...media.codecs.values()]).flat().filter(ci=>ci.name===requestedMediaCodecType);var receiverCodecs=parsedOffer.avMedia.filter(media=>requestedMid===media.mid).map(media=>[...media.codecs.values()]).flat().filter(ci=>ci.name===requestedMediaCodecType);if(!senderCodecs||!receiverCodecs||senderCodecs.length===0||receiverCodecs.length===0){throw new Error("sender codecs or receiver codecs is undefined or empty");}var senderCodec=senderCodecs[0];var targetCodec=receiverCodecs.find(receiverCodec=>{return areCodecsCompatible(senderCodec,receiverCodec);});if(!targetCodec||!targetCodec.pt){throw new Error("ingress payload type is not well defined in receiver codecs");}return targetCodec.pt;}createOffer(){return __awaiter(this,void 0,void 0,function*(){if(!this.pc.getLocalDescription()){this.midPredictor.allocateMidForDatachannel();}return new Promise(createOfferResolve=>{this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){var _a;if(this.setAnswerResolve!==undefined){throw new Error("Tried to start a new createOffer flow before the old one had finished");}var setAnswerPromise=new Promise(resolve=>{this.setAnswerResolve=resolve;});var offer=yield this.pc.createOffer();if(!offer.sdp){throw new Error('No SDP offer');}offer.sdp=this.preProcessLocalOffer(offer.sdp);yield this.pc.setLocalDescription(offer);var sdpToSend=this.prepareLocalOfferForRemoteServer((_a=this.pc.getLocalDescription())===null||_a===void 0?void 0:_a.sdp);createOfferResolve({type:'offer',sdp:sdpToSend});yield setAnswerPromise;}));});});}setAnswer(answer){return __awaiter(this,void 0,void 0,function*(){var sdp=this.preProcessRemoteAnswer(answer);if(!this.setAnswerResolve){throw new Error("Call to setAnswer without having previously called createOffer");}return this.pc.setRemoteDescription({type:'answer',sdp}).then(()=>__awaiter(this,void 0,void 0,function*(){if(this.setAnswerResolve){this.setAnswerResolve();this.setAnswerResolve=undefined;}else {logger$4.debug("setAnswerResolve function was cleared between setAnswer and result of setRemoteDescription");}}));});}doLocalOfferAnswer(){var _a;return __awaiter(this,void 0,void 0,function*(){var offer=yield this.pc.createOffer();if(!offer.sdp){throw new Error('No SDP offer');}offer.sdp=this.preProcessLocalOffer(offer.sdp);yield this.pc.setLocalDescription(offer);var answer=this.preProcessRemoteAnswer((_a=this.pc.getRemoteDescription())===null||_a===void 0?void 0:_a.sdp);return this.pc.setRemoteDescription({type:'answer',sdp:answer});});}queueLocalOfferAnswer(){return __awaiter(this,void 0,void 0,function*(){return this.offerAnswerQueue.push(()=>__awaiter(this,void 0,void 0,function*(){yield this.doLocalOfferAnswer();}));});}enableMultistreamAudio(enabled){var sendTransceiver=this.sendTransceivers.get(MediaType.AudioMain);if(sendTransceiver){return sendTransceiver.setActive(enabled);}return false;}preProcessLocalOffer(offer){var parsed=parse$2(offer);filterCodecs(parsed,['h264','opus','rtx']);setMaxBandwidth(parsed,20000000);parsed.avMedia.filter(av=>av.direction==='recvonly').forEach(av=>{var transceiver=this.getRecvTransceiverByMidOrThrow(av.mid);transceiver.signalLocalStreams(av);});parsed.avMedia.filter(av=>av.direction==='sendrecv'||av.direction==='inactive').forEach(av=>{var transceiver=this.getSendTransceiverByMidOrThrow(av.mid);transceiver.signalStreams(av);});if(getBrowserDetails().name!=='Firefox'){setupBundle(parsed,this.options.bundlePolicy,this.midPredictor.getMidMap());}return parsed.toString();}prepareLocalOfferForRemoteServer(offer){var parsed=parse$2(offer);var midContentMap=new Map();this.sendTransceivers.forEach((transceiver,mediaType)=>{midContentMap.set(transceiver.mid,getMediaContent(mediaType));});injectContentTypes(parsed,midContentMap);var csiMap=new Map();this.sendTransceivers.forEach((transceiver,mediaType)=>{csiMap.set(mediaType,transceiver.csi);});injectJmpAttributes(parsed,csiMap,this.options.streamSignalingMode);filterRecvOnlyMlines(parsed);injectDummyCandidates(parsed);parsed.avMedia.filter(av=>av.direction==='sendrecv'&&av.type==='video').forEach(av=>{var ssrcGroup=av.ssrcGroups.find(sg=>sg.semantics==='SIM');if(ssrcGroup){ssrcGroup.ssrcs.forEach((ssrc,index)=>{av.addLine(new SsrcLine$1(ssrc,'fmtp',"* max-fs=".concat(simulcastMaxFrameSizes[index])));});}});if(getBrowserDetails().name==='Firefox'){setupBundle(parsed,this.options.bundlePolicy,this.midPredictor.getMidMap());if(this.options.bundlePolicy==='max-bundle'){parsed.media.forEach((mline,index)=>{if(index>0){mline.port=parsed.media[0].port;}});}}return parsed.toString();}preProcessRemoteAnswer(answer){var _a;var parsedAnswer=parse$2(answer);var parsedOffer=parse$2((_a=this.pc.getLocalDescription())===null||_a===void 0?void 0:_a.sdp);var recvTransceiversByMid=new Map([...this.recvTransceivers.values()].flat().map(t=>[t.mid,t]));matchMlinesInAnswer(parsedOffer,parsedAnswer,recvTransceiversByMid);if(getBrowserDetails().name==='Firefox'){setupBundle(parsedAnswer,this.options.bundlePolicy,this.midPredictor.getMidMap());if(this.options.bundlePolicy==='max-bundle'){var{ufrag,pwd}=parsedAnswer.media[0].iceInfo;parsedAnswer.media.forEach((mline,index)=>{if(index>0){mline.iceInfo.ufrag=ufrag;mline.iceInfo.pwd=pwd;}});}}return parsedAnswer.toString();}getSendTransceiverOrThrow(mediaType){var sendTransceiver=this.sendTransceivers.get(mediaType);if(!sendTransceiver){throw new Error("Unable to find matching transceiver for media type ".concat(mediaType));}return sendTransceiver;}getSendTransceiverByMidOrThrow(mid){var transceiver=[...this.sendTransceivers.values()].find(t=>t.mid===mid);if(!transceiver){throw new Error("Unable to find send transceiver with mid ".concat(mid));}return transceiver;}getRecvTransceiverByMidOrThrow(mid){var transceiver=[...this.recvTransceivers.values()].flat().find(t=>t.mid===mid);if(!transceiver){throw new Error("Unable to find recv transceiver with mid ".concat(mid));}return transceiver;}getPublishedTracks(){return [...this.sendTransceivers.values()].map(transceiver=>transceiver.publishedTrack).filter(Boolean);}setCodecParameters(mediaType,parameters){return __awaiter(this,void 0,void 0,function*(){var transceiver=this.sendTransceivers.get(mediaType);transceiver===null||transceiver===void 0?void 0:transceiver.setCodecParameters(parameters);if(this.pc.getRemoteDescription()){yield this.queueLocalOfferAnswer();}});}deleteCodecParameters(mediaType,parameters){return __awaiter(this,void 0,void 0,function*(){var transceiver=this.sendTransceivers.get(mediaType);transceiver===null||transceiver===void 0?void 0:transceiver.deleteCodecParameters(parameters);if(this.pc.getRemoteDescription()){yield this.queueLocalOfferAnswer();}});}requestMedia(mediaType,streamRequests){var _a;var task=()=>{var _a;var jmpSession=this.jmpSessions.get(mediaType);if(!jmpSession){logger$4.error("Unable to find jmp session for ".concat(mediaType));return;}var requestedReceiveSlotIds=[];streamRequests.forEach(sr=>{sr.receiveSlots.forEach(rs=>{if(!rs.id){logger$4.error("Running stream request task, but ReceiveSlot ID is missing!");return;}requestedReceiveSlotIds.push(rs.id);});});(_a=this.recvTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.forEach(transceiver=>{if(!requestedReceiveSlotIds.some(id=>compareStreamIds(id,transceiver.receiveSlot.id))){transceiver.receiveSlot._updateSource('no source',undefined);}});jmpSession.sendRequests(streamRequests.map(sr=>sr._toJmpStreamRequest()));};if(((_a=this.dataChannel)===null||_a===void 0?void 0:_a.readyState)==='open'){task();}else {this.pendingJmpTasks.push(task);}}renewPeerConnection(userOptions){if(userOptions){this.options=Object.assign(Object.assign({},this.options),userOptions);}logger$4.info("Renewing multistream connection with options ".concat(JSON.stringify(this.options)));this.midPredictor.reset();this.initializePeerConnection();var mainSceneId=generateSceneId();var slidesSceneId=generateSceneId();this.sendTransceivers.forEach((transceiver,mediaType)=>{var _a;var mediaContent=getMediaContent(mediaType);var sceneId=mediaContent===MediaContent$1.Main?mainSceneId:slidesSceneId;var mid=this.midPredictor.getNextMid(mediaType);transceiver.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'sendrecv',sendEncodings:getMediaFamily$1(mediaType)===MediaFamily.Video?this.getVideoEncodingOptions(mediaContent):undefined}));transceiver.mid=mid;transceiver.csi=generateCsi(getMediaFamily$1(mediaType),sceneId);transceiver.resetStreamSignaler();(_a=this.jmpSessions.get(mediaType))===null||_a===void 0?void 0:_a.close();this.createJmpSession(mediaType);});this.recvTransceivers.forEach((transceivers,mediaType)=>{transceivers.forEach(t=>{var mid=this.midPredictor.getNextMid(mediaType);t.replaceTransceiver(this.pc.addTransceiver(toMediaStreamTrackKind(mediaType),{direction:'recvonly'}));t.mid=mid;});});}getReceiveSlotById(id){return [...this.recvTransceivers.values()].flat().map(transceiver=>transceiver.receiveSlot).find(receiveSlot=>{var receiveSlotId=receiveSlot.id||{};return Object.keys(receiveSlotId).length===Object.keys(id).length&&Object.keys(receiveSlotId).every(key=>Object.prototype.hasOwnProperty.call(id,key)&&receiveSlotId[key]===id[key]);});}getStats(){return this.statsManager.getStats();}getTransceiverStats(){return __awaiter(this,void 0,void 0,function*(){return organizeTransceiverStats(this.sendTransceivers,this.recvTransceivers);});}preProcessStats(stats){return __awaiter(this,void 0,void 0,function*(){yield Promise.all([...this.sendTransceivers.entries()].map(_ref8=>{var[mediaType,transceiver]=_ref8;return __awaiter(this,void 0,void 0,function*(){(yield transceiver.getStats()).forEach(senderStats=>{var _a;if(senderStats.type==='outbound-rtp'){var statsToModify=stats.get(senderStats.id);statsToModify.mid=transceiver.mid;statsToModify.csi=transceiver.csi;statsToModify.mediaType=mediaType;var trackSettings=(_a=transceiver.publishedTrack)===null||_a===void 0?void 0:_a.underlyingTrack.getSettings();if(trackSettings===null||trackSettings===void 0?void 0:trackSettings.frameRate){statsToModify.targetFrameRate=trackSettings===null||trackSettings===void 0?void 0:trackSettings.frameRate;}stats.set(senderStats.id,statsToModify);}});});}));yield Promise.all([...this.recvTransceivers.entries()].map(_ref9=>{var[mediaType,transceivers]=_ref9;return __awaiter(this,void 0,void 0,function*(){yield Promise.all(transceivers.map(transceiver=>__awaiter(this,void 0,void 0,function*(){(yield transceiver.getStats()).forEach(receiverStats=>{var _a;if(receiverStats.type==='inbound-rtp'){var statsToModify=stats.get(receiverStats.id);statsToModify.mid=(_a=transceiver.receiveSlot.id)===null||_a===void 0?void 0:_a.mid;statsToModify.csi=transceiver.receiveSlot.currentRxCsi;statsToModify.mediaType=mediaType;Object.assign(statsToModify,transceiver.receiverId);stats.set(receiverStats.id,statsToModify);}});})));});}));});}attachMetricsObserver(){rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(),data=>this.metricsCallback(data),5000);}setMetricsCallback(callback){this.metricsCallback=callback;}setOveruseUpdateCallback(callback){this.overuseUpdateCallback=callback;}getCsiByMediaType(mediaType){var _a;return (_a=this.sendTransceivers.get(mediaType))===null||_a===void 0?void 0:_a.csi;}getAllCsis(){return {audioMain:this.getCsiByMediaType(MediaType.AudioMain),audioSlides:this.getCsiByMediaType(MediaType.AudioSlides),videoMain:this.getCsiByMediaType(MediaType.VideoMain),videoSlides:this.getCsiByMediaType(MediaType.VideoSlides)};}}class StreamRequest{constructor(policy,policySpecificInfo,receiveSlots,maxPayloadBitsPerSecond){var codecInfos=arguments.length>4&&arguments[4]!==undefined?arguments[4]:[];this.policy=policy;this.policySpecificInfo=policySpecificInfo;this.receiveSlots=receiveSlots;this.maxPayloadBitsPerSecond=maxPayloadBitsPerSecond;this.codecInfos=codecInfos;}_toJmpStreamRequest(){return new StreamRequest$1(this.policy,this.policySpecificInfo,this.receiveSlots.map(rs=>rs.id),this.maxPayloadBitsPerSecond,this.codecInfos);}}
|
|
5833
|
+
|
|
5834
|
+
var defaultLogger = {
|
|
5835
|
+
info: function info() {
|
|
5836
|
+
return console.info(...arguments);
|
|
5837
|
+
},
|
|
5838
|
+
log: function log() {
|
|
5839
|
+
return console.log(...arguments);
|
|
5840
|
+
},
|
|
5841
|
+
error: function error() {
|
|
5842
|
+
return console.error(...arguments);
|
|
5843
|
+
},
|
|
5844
|
+
warn: function warn() {
|
|
5845
|
+
return console.warn(...arguments);
|
|
5846
|
+
},
|
|
5847
|
+
trace: function trace() {
|
|
5848
|
+
return console.trace(...arguments);
|
|
5849
|
+
},
|
|
5850
|
+
debug: function debug() {
|
|
5851
|
+
return console.debug(...arguments);
|
|
5852
|
+
}
|
|
5853
|
+
};
|
|
5854
|
+
var currentLogger = defaultLogger;
|
|
5855
|
+
var getLogger = () => currentLogger;
|
|
5856
|
+
var configureWcmeLogger = debugId => {
|
|
5857
|
+
var logger = getLogger();
|
|
5858
|
+
setLogHandler((messages, context) => {
|
|
5859
|
+
var logMessages = Array.from(messages).map(message => typeof message === 'object' ? JSON.stringify(message) : message);
|
|
5860
|
+
logMessages.unshift("".concat(debugId || '', ":[").concat(context.name, "]"));
|
|
5861
|
+
switch (context.level.name) {
|
|
5862
|
+
case 'TRACE':
|
|
5863
|
+
logger.trace(...logMessages);
|
|
5864
|
+
break;
|
|
5865
|
+
case 'DEBUG':
|
|
5866
|
+
logger.debug(...logMessages);
|
|
5867
|
+
break;
|
|
5868
|
+
case 'INFO':
|
|
5869
|
+
logger.info(...logMessages);
|
|
5870
|
+
break;
|
|
5871
|
+
case 'WARN':
|
|
5872
|
+
logger.warn(...logMessages);
|
|
5873
|
+
break;
|
|
5874
|
+
case 'ERROR':
|
|
5875
|
+
logger.error(...logMessages);
|
|
5876
|
+
break;
|
|
5877
|
+
}
|
|
5878
|
+
});
|
|
5879
|
+
};
|
|
5880
|
+
var setLogger = newLogger => {
|
|
5881
|
+
if (newLogger) {
|
|
5882
|
+
currentLogger = newLogger;
|
|
5883
|
+
} else {
|
|
5884
|
+
currentLogger = defaultLogger;
|
|
5885
|
+
}
|
|
5886
|
+
configureWcmeLogger();
|
|
5887
|
+
};
|
|
5888
|
+
var getErrorDescription = error => {
|
|
5889
|
+
return error ? error.stack ? "".concat(error.message, ": ").concat(error.stack) : "".concat(error) : '';
|
|
5890
|
+
};
|
|
5891
|
+
|
|
5892
|
+
var NUM = '\\d+';
|
|
5893
|
+
var SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
|
|
5894
|
+
var ANY_NON_WS = '\\S+';
|
|
5895
|
+
var SP = '\\s';
|
|
5896
|
+
var REST = '.+';
|
|
5897
|
+
class Line {}
|
|
5898
|
+
var _a$5;
|
|
5899
|
+
class BandwidthLine extends Line {
|
|
5900
|
+
constructor(bandwidthType, bandwidth) {
|
|
5901
|
+
super();
|
|
5902
|
+
this.bandwidthType = bandwidthType;
|
|
5903
|
+
this.bandwidth = bandwidth;
|
|
5904
|
+
}
|
|
5905
|
+
static fromSdpLine(line) {
|
|
5906
|
+
if (!BandwidthLine.regex.test(line)) {
|
|
5907
|
+
return undefined;
|
|
5908
|
+
}
|
|
5909
|
+
var tokens = line.match(BandwidthLine.regex);
|
|
5910
|
+
var bandwidthType = tokens[1];
|
|
5911
|
+
var bandwidth = parseInt(tokens[2], 10);
|
|
5912
|
+
return new BandwidthLine(bandwidthType, bandwidth);
|
|
5913
|
+
}
|
|
5914
|
+
toSdpLine() {
|
|
5915
|
+
return "b=".concat(this.bandwidthType, ":").concat(this.bandwidth);
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
_a$5 = BandwidthLine;
|
|
5919
|
+
BandwidthLine.BW_TYPE_REGEX = 'CT|AS|TIAS';
|
|
5920
|
+
BandwidthLine.regex = new RegExp("^(".concat(_a$5.BW_TYPE_REGEX, "):(").concat(NUM, ")"));
|
|
5921
|
+
class BundleGroupLine extends Line {
|
|
5922
|
+
constructor(mids) {
|
|
5923
|
+
super();
|
|
5924
|
+
this.mids = mids;
|
|
5925
|
+
}
|
|
5926
|
+
static fromSdpLine(line) {
|
|
5927
|
+
if (!BundleGroupLine.regex.test(line)) {
|
|
5928
|
+
return undefined;
|
|
5929
|
+
}
|
|
5930
|
+
var tokens = line.match(BundleGroupLine.regex);
|
|
5931
|
+
var mids = tokens[1].split(' ');
|
|
5932
|
+
return new BundleGroupLine(mids);
|
|
5933
|
+
}
|
|
5934
|
+
toSdpLine() {
|
|
5935
|
+
return "a=group:BUNDLE ".concat(this.mids.join(' '));
|
|
5936
|
+
}
|
|
5937
|
+
}
|
|
5938
|
+
BundleGroupLine.regex = new RegExp("^group:BUNDLE (".concat(REST, ")"));
|
|
5939
|
+
var _a$4;
|
|
5940
|
+
class CandidateLine extends Line {
|
|
5941
|
+
constructor(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions) {
|
|
5942
|
+
super();
|
|
5943
|
+
this.foundation = foundation;
|
|
5944
|
+
this.componentId = componentId;
|
|
5945
|
+
this.transport = transport;
|
|
5946
|
+
this.priority = priority;
|
|
5947
|
+
this.connectionAddress = connectionAddress;
|
|
5948
|
+
this.port = port;
|
|
5949
|
+
this.candidateType = candidateType;
|
|
5950
|
+
this.relAddr = relAddr;
|
|
5951
|
+
this.relPort = relPort;
|
|
5952
|
+
this.candidateExtensions = candidateExtensions;
|
|
5953
|
+
}
|
|
5954
|
+
static fromSdpLine(line) {
|
|
5955
|
+
if (!CandidateLine.regex.test(line)) {
|
|
5956
|
+
return undefined;
|
|
5957
|
+
}
|
|
5958
|
+
var tokens = line.match(CandidateLine.regex);
|
|
5959
|
+
var foundation = tokens[1];
|
|
5960
|
+
var componentId = parseInt(tokens[2], 10);
|
|
5961
|
+
var transport = tokens[3];
|
|
5962
|
+
var priority = parseInt(tokens[4], 10);
|
|
5963
|
+
var connectionAddress = tokens[5];
|
|
5964
|
+
var port = parseInt(tokens[6], 10);
|
|
5965
|
+
var candidateType = tokens[7];
|
|
5966
|
+
var relAddr = tokens[8];
|
|
5967
|
+
var relPort = tokens[9] ? parseInt(tokens[9], 10) : undefined;
|
|
5968
|
+
var candidateExtensions = tokens[10];
|
|
5969
|
+
return new CandidateLine(foundation, componentId, transport, priority, connectionAddress, port, candidateType, relAddr, relPort, candidateExtensions);
|
|
5970
|
+
}
|
|
5971
|
+
toSdpLine() {
|
|
5972
|
+
var str = '';
|
|
5973
|
+
str += "a=candidate:".concat(this.foundation, " ").concat(this.componentId, " ").concat(this.transport, " ").concat(this.priority, " ").concat(this.connectionAddress, " ").concat(this.port, " typ ").concat(this.candidateType);
|
|
5974
|
+
if (this.relAddr) {
|
|
5975
|
+
str += " raddr ".concat(this.relAddr);
|
|
5976
|
+
}
|
|
5977
|
+
if (this.relPort) {
|
|
5978
|
+
str += " rport ".concat(this.relPort);
|
|
5979
|
+
}
|
|
5980
|
+
if (this.candidateExtensions) {
|
|
5981
|
+
str += " ".concat(this.candidateExtensions);
|
|
5982
|
+
}
|
|
5983
|
+
return str;
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
_a$4 = CandidateLine;
|
|
5987
|
+
CandidateLine.ICE_CHARS = "[a-zA-Z0-9+/]+";
|
|
5988
|
+
CandidateLine.regex = new RegExp("^candidate:(".concat(_a$4.ICE_CHARS, ") (").concat(NUM, ") (").concat(ANY_NON_WS, ") (").concat(NUM, ") (").concat(ANY_NON_WS, ") (").concat(NUM, ") typ (").concat(ANY_NON_WS, ")(?: raddr (").concat(ANY_NON_WS, "))?(?: rport (").concat(NUM, "))?(?: (").concat(REST, "))?"));
|
|
5989
|
+
class ConnectionLine extends Line {
|
|
5990
|
+
constructor(netType, addrType, ipAddr) {
|
|
5991
|
+
super();
|
|
5992
|
+
this.netType = netType;
|
|
5993
|
+
this.addrType = addrType;
|
|
5994
|
+
this.ipAddr = ipAddr;
|
|
5995
|
+
}
|
|
5996
|
+
static fromSdpLine(line) {
|
|
5997
|
+
if (!ConnectionLine.regex.test(line)) {
|
|
5998
|
+
return undefined;
|
|
5999
|
+
}
|
|
6000
|
+
var tokens = line.match(ConnectionLine.regex);
|
|
6001
|
+
var netType = tokens[1];
|
|
6002
|
+
var addrType = tokens[2];
|
|
6003
|
+
var ipAddr = tokens[3];
|
|
6004
|
+
return new ConnectionLine(netType, addrType, ipAddr);
|
|
6005
|
+
}
|
|
6006
|
+
toSdpLine() {
|
|
6007
|
+
return "c=".concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
6010
|
+
ConnectionLine.regex = new RegExp("^(".concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ")"));
|
|
6011
|
+
class ContentLine extends Line {
|
|
6012
|
+
constructor(values) {
|
|
6013
|
+
super();
|
|
6014
|
+
this.values = values;
|
|
6015
|
+
}
|
|
6016
|
+
static fromSdpLine(line) {
|
|
6017
|
+
if (!ContentLine.regex.test(line)) {
|
|
6018
|
+
return undefined;
|
|
6019
|
+
}
|
|
6020
|
+
var tokens = line.match(ContentLine.regex);
|
|
6021
|
+
var values = tokens[1].split(',');
|
|
6022
|
+
return new ContentLine(values);
|
|
6023
|
+
}
|
|
6024
|
+
toSdpLine() {
|
|
6025
|
+
return "a=content:".concat(this.values.join(','));
|
|
6026
|
+
}
|
|
6027
|
+
}
|
|
6028
|
+
ContentLine.regex = new RegExp("^content:(".concat(REST, ")$"));
|
|
6029
|
+
class DirectionLine extends Line {
|
|
6030
|
+
constructor(direction) {
|
|
6031
|
+
super();
|
|
6032
|
+
this.direction = direction;
|
|
6033
|
+
}
|
|
6034
|
+
static fromSdpLine(line) {
|
|
6035
|
+
if (!DirectionLine.regex.test(line)) {
|
|
6036
|
+
return undefined;
|
|
6037
|
+
}
|
|
6038
|
+
var tokens = line.match(DirectionLine.regex);
|
|
6039
|
+
var direction = tokens[1];
|
|
6040
|
+
return new DirectionLine(direction);
|
|
6041
|
+
}
|
|
6042
|
+
toSdpLine() {
|
|
6043
|
+
return "a=".concat(this.direction);
|
|
6044
|
+
}
|
|
6045
|
+
}
|
|
6046
|
+
DirectionLine.regex = /^(sendrecv|sendonly|recvonly|inactive)$/;
|
|
6047
|
+
var _a$3;
|
|
6048
|
+
class ExtMapLine extends Line {
|
|
6049
|
+
constructor(id, uri, direction, extensionAttributes) {
|
|
6050
|
+
super();
|
|
6051
|
+
this.id = id;
|
|
6052
|
+
this.uri = uri;
|
|
6053
|
+
this.direction = direction;
|
|
6054
|
+
this.extensionAttributes = extensionAttributes;
|
|
6055
|
+
}
|
|
6056
|
+
static fromSdpLine(line) {
|
|
6057
|
+
if (!ExtMapLine.regex.test(line)) {
|
|
6058
|
+
return undefined;
|
|
6059
|
+
}
|
|
6060
|
+
var tokens = line.match(ExtMapLine.regex);
|
|
6061
|
+
var id = parseInt(tokens[1], 10);
|
|
6062
|
+
var direction = tokens[2];
|
|
6063
|
+
var uri = tokens[3];
|
|
6064
|
+
var extensionAttributes = tokens[4];
|
|
6065
|
+
return new ExtMapLine(id, uri, direction, extensionAttributes);
|
|
6066
|
+
}
|
|
6067
|
+
toSdpLine() {
|
|
6068
|
+
var str = '';
|
|
6069
|
+
str += "a=extmap:".concat(this.id);
|
|
6070
|
+
if (this.direction) {
|
|
6071
|
+
str += "/".concat(this.direction);
|
|
6072
|
+
}
|
|
6073
|
+
str += " ".concat(this.uri);
|
|
6074
|
+
if (this.extensionAttributes) {
|
|
6075
|
+
str += " ".concat(this.extensionAttributes);
|
|
6076
|
+
}
|
|
6077
|
+
return str;
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
_a$3 = ExtMapLine;
|
|
6081
|
+
ExtMapLine.EXTMAP_DIRECTION = "sendonly|recvonly|sendrecv|inactive";
|
|
6082
|
+
ExtMapLine.regex = new RegExp("^extmap:(".concat(NUM, ")(?:/(").concat(_a$3.EXTMAP_DIRECTION, "))? (").concat(ANY_NON_WS, ")(?: (").concat(REST, "))?"));
|
|
6083
|
+
class FingerprintLine extends Line {
|
|
6084
|
+
constructor(fingerprint) {
|
|
6085
|
+
super();
|
|
6086
|
+
this.fingerprint = fingerprint;
|
|
6087
|
+
}
|
|
6088
|
+
static fromSdpLine(line) {
|
|
6089
|
+
if (!FingerprintLine.regex.test(line)) {
|
|
6090
|
+
return undefined;
|
|
6091
|
+
}
|
|
6092
|
+
var tokens = line.match(FingerprintLine.regex);
|
|
6093
|
+
var fingerprint = tokens[1];
|
|
6094
|
+
return new FingerprintLine(fingerprint);
|
|
6095
|
+
}
|
|
6096
|
+
toSdpLine() {
|
|
6097
|
+
return "a=fingerprint:".concat(this.fingerprint);
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
FingerprintLine.regex = new RegExp("^fingerprint:(".concat(REST, ")"));
|
|
6101
|
+
function parseFmtpParams(fmtpParams) {
|
|
6102
|
+
fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
|
|
6103
|
+
var fmtpObj = new Map();
|
|
6104
|
+
if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
|
|
6105
|
+
fmtpObj.set(fmtpParams, undefined);
|
|
6106
|
+
return fmtpObj;
|
|
6107
|
+
}
|
|
6108
|
+
fmtpParams.split(';').forEach(param => {
|
|
6109
|
+
var paramArr = param && param.split('=');
|
|
6110
|
+
if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
|
|
6111
|
+
throw new Error("Fmtp params is invalid with ".concat(fmtpParams));
|
|
6112
|
+
}
|
|
6113
|
+
fmtpObj.set(paramArr[0], paramArr[1]);
|
|
6114
|
+
});
|
|
6115
|
+
return fmtpObj;
|
|
6116
|
+
}
|
|
6117
|
+
class FmtpLine extends Line {
|
|
6118
|
+
constructor(payloadType, params) {
|
|
6119
|
+
super();
|
|
6120
|
+
this.payloadType = payloadType;
|
|
6121
|
+
this.params = params;
|
|
6122
|
+
}
|
|
6123
|
+
static fromSdpLine(line) {
|
|
6124
|
+
if (!FmtpLine.regex.test(line)) {
|
|
6125
|
+
return undefined;
|
|
6126
|
+
}
|
|
6127
|
+
var tokens = line.match(FmtpLine.regex);
|
|
6128
|
+
var payloadType = parseInt(tokens[1], 10);
|
|
6129
|
+
var params = tokens[2];
|
|
6130
|
+
return new FmtpLine(payloadType, parseFmtpParams(params));
|
|
6131
|
+
}
|
|
6132
|
+
toSdpLine() {
|
|
6133
|
+
var fmtParams = Array.from(this.params.keys()).map(key => {
|
|
6134
|
+
if (this.params.get(key) !== undefined) {
|
|
6135
|
+
return "".concat(key, "=").concat(this.params.get(key));
|
|
6136
|
+
}
|
|
6137
|
+
return "".concat(key);
|
|
6138
|
+
}).join(';');
|
|
6139
|
+
return "a=fmtp:".concat(this.payloadType, " ").concat(fmtParams);
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6142
|
+
FmtpLine.regex = new RegExp("^fmtp:(".concat(NUM, ") (").concat(REST, ")"));
|
|
6143
|
+
class IceOptionsLine extends Line {
|
|
6144
|
+
constructor(options) {
|
|
6145
|
+
super();
|
|
6146
|
+
this.options = options;
|
|
6147
|
+
}
|
|
6148
|
+
static fromSdpLine(line) {
|
|
6149
|
+
if (!IceOptionsLine.regex.test(line)) {
|
|
6150
|
+
return undefined;
|
|
6151
|
+
}
|
|
6152
|
+
var tokens = line.match(IceOptionsLine.regex);
|
|
6153
|
+
var options = tokens[1].split(' ');
|
|
6154
|
+
return new IceOptionsLine(options);
|
|
6155
|
+
}
|
|
6156
|
+
toSdpLine() {
|
|
6157
|
+
return "a=ice-options:".concat(this.options.join(' '));
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
IceOptionsLine.regex = new RegExp("^ice-options:(".concat(REST, ")$"));
|
|
6161
|
+
class IcePwdLine extends Line {
|
|
6162
|
+
constructor(pwd) {
|
|
6163
|
+
super();
|
|
6164
|
+
this.pwd = pwd;
|
|
6165
|
+
}
|
|
6166
|
+
static fromSdpLine(line) {
|
|
6167
|
+
if (!IcePwdLine.regex.test(line)) {
|
|
6168
|
+
return undefined;
|
|
6169
|
+
}
|
|
6170
|
+
var tokens = line.match(IcePwdLine.regex);
|
|
6171
|
+
var pwd = tokens[1];
|
|
6172
|
+
return new IcePwdLine(pwd);
|
|
6173
|
+
}
|
|
6174
|
+
toSdpLine() {
|
|
6175
|
+
return "a=ice-pwd:".concat(this.pwd);
|
|
6176
|
+
}
|
|
6177
|
+
}
|
|
6178
|
+
IcePwdLine.regex = new RegExp("^ice-pwd:(".concat(ANY_NON_WS, ")$"));
|
|
6179
|
+
class IceUfragLine extends Line {
|
|
6180
|
+
constructor(ufrag) {
|
|
6181
|
+
super();
|
|
6182
|
+
this.ufrag = ufrag;
|
|
6183
|
+
}
|
|
6184
|
+
static fromSdpLine(line) {
|
|
6185
|
+
if (!IceUfragLine.regex.test(line)) {
|
|
6186
|
+
return undefined;
|
|
6187
|
+
}
|
|
6188
|
+
var tokens = line.match(IceUfragLine.regex);
|
|
6189
|
+
var ufrag = tokens[1];
|
|
6190
|
+
return new IceUfragLine(ufrag);
|
|
6191
|
+
}
|
|
6192
|
+
toSdpLine() {
|
|
6193
|
+
return "a=ice-ufrag:".concat(this.ufrag);
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
IceUfragLine.regex = new RegExp("^ice-ufrag:(".concat(ANY_NON_WS, ")$"));
|
|
6197
|
+
class MaxMessageSizeLine extends Line {
|
|
6198
|
+
constructor(maxMessageSize) {
|
|
6199
|
+
super();
|
|
6200
|
+
this.maxMessageSize = maxMessageSize;
|
|
6201
|
+
}
|
|
6202
|
+
static fromSdpLine(line) {
|
|
6203
|
+
if (!MaxMessageSizeLine.regex.test(line)) {
|
|
6204
|
+
return undefined;
|
|
6205
|
+
}
|
|
6206
|
+
var tokens = line.match(MaxMessageSizeLine.regex);
|
|
6207
|
+
var maxMessageSize = parseInt(tokens[1], 10);
|
|
6208
|
+
return new MaxMessageSizeLine(maxMessageSize);
|
|
6209
|
+
}
|
|
6210
|
+
toSdpLine() {
|
|
6211
|
+
return "a=max-message-size:".concat(this.maxMessageSize);
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6214
|
+
MaxMessageSizeLine.regex = new RegExp("^max-message-size:(".concat(NUM, ")"));
|
|
6215
|
+
var _a$2;
|
|
6216
|
+
class MediaLine extends Line {
|
|
6217
|
+
constructor(type, port, protocol, formats) {
|
|
6218
|
+
super();
|
|
6219
|
+
this.type = type;
|
|
6220
|
+
this.port = port;
|
|
6221
|
+
this.protocol = protocol;
|
|
6222
|
+
this.formats = formats;
|
|
6223
|
+
}
|
|
6224
|
+
static fromSdpLine(line) {
|
|
6225
|
+
if (!MediaLine.regex.test(line)) {
|
|
6226
|
+
return undefined;
|
|
6227
|
+
}
|
|
6228
|
+
var tokens = line.match(MediaLine.regex);
|
|
6229
|
+
var type = tokens[1];
|
|
6230
|
+
var port = parseInt(tokens[2], 10);
|
|
6231
|
+
var protocol = tokens[3];
|
|
6232
|
+
var formats = tokens[4].split(' ');
|
|
6233
|
+
return new MediaLine(type, port, protocol, formats);
|
|
6234
|
+
}
|
|
6235
|
+
toSdpLine() {
|
|
6236
|
+
return "m=".concat(this.type, " ").concat(this.port, " ").concat(this.protocol, " ").concat(this.formats.join(' '));
|
|
6237
|
+
}
|
|
6238
|
+
}
|
|
6239
|
+
_a$2 = MediaLine;
|
|
6240
|
+
MediaLine.MEDIA_TYPE = 'audio|video|application';
|
|
6241
|
+
MediaLine.regex = new RegExp("^(".concat(_a$2.MEDIA_TYPE, ") (").concat(NUM, ") (").concat(ANY_NON_WS, ") (").concat(REST, ")"));
|
|
6242
|
+
class MidLine extends Line {
|
|
6243
|
+
constructor(mid) {
|
|
6244
|
+
super();
|
|
6245
|
+
this.mid = mid;
|
|
6246
|
+
}
|
|
6247
|
+
static fromSdpLine(line) {
|
|
6248
|
+
if (!MidLine.regex.test(line)) {
|
|
6249
|
+
return undefined;
|
|
6250
|
+
}
|
|
6251
|
+
var tokens = line.match(MidLine.regex);
|
|
6252
|
+
var mid = tokens[1];
|
|
6253
|
+
return new MidLine(mid);
|
|
6254
|
+
}
|
|
6255
|
+
toSdpLine() {
|
|
6256
|
+
return "a=mid:".concat(this.mid);
|
|
6257
|
+
}
|
|
6258
|
+
}
|
|
6259
|
+
MidLine.regex = new RegExp("^mid:(".concat(ANY_NON_WS, ")$"));
|
|
6260
|
+
class OriginLine extends Line {
|
|
6261
|
+
constructor(username, sessionId, sessionVersion, netType, addrType, ipAddr) {
|
|
6262
|
+
super();
|
|
6263
|
+
this.username = username;
|
|
6264
|
+
this.sessionId = sessionId;
|
|
6265
|
+
this.sessionVersion = sessionVersion;
|
|
6266
|
+
this.netType = netType;
|
|
6267
|
+
this.addrType = addrType;
|
|
6268
|
+
this.ipAddr = ipAddr;
|
|
6269
|
+
}
|
|
6270
|
+
static fromSdpLine(line) {
|
|
6271
|
+
if (!OriginLine.regex.test(line)) {
|
|
6272
|
+
return undefined;
|
|
6273
|
+
}
|
|
6274
|
+
var tokens = line.match(OriginLine.regex);
|
|
6275
|
+
var username = tokens[1];
|
|
6276
|
+
var sessionId = tokens[2];
|
|
6277
|
+
var sessionVersion = parseInt(tokens[3], 10);
|
|
6278
|
+
var netType = tokens[4];
|
|
6279
|
+
var addrType = tokens[5];
|
|
6280
|
+
var ipAddr = tokens[6];
|
|
6281
|
+
return new OriginLine(username, sessionId, sessionVersion, netType, addrType, ipAddr);
|
|
6282
|
+
}
|
|
6283
|
+
toSdpLine() {
|
|
6284
|
+
return "o=".concat(this.username, " ").concat(this.sessionId, " ").concat(this.sessionVersion, " ").concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
|
|
6285
|
+
}
|
|
6286
|
+
}
|
|
6287
|
+
OriginLine.regex = new RegExp("^(".concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(NUM, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ")"));
|
|
6288
|
+
var _a$1;
|
|
6289
|
+
class RidLine extends Line {
|
|
6290
|
+
constructor(id, direction, params) {
|
|
6291
|
+
super();
|
|
6292
|
+
this.id = id;
|
|
6293
|
+
this.direction = direction;
|
|
6294
|
+
this.params = params;
|
|
6295
|
+
}
|
|
6296
|
+
static fromSdpLine(line) {
|
|
6297
|
+
if (!RidLine.regex.test(line)) {
|
|
6298
|
+
return undefined;
|
|
6299
|
+
}
|
|
6300
|
+
var tokens = line.match(RidLine.regex);
|
|
6301
|
+
var id = tokens[1];
|
|
6302
|
+
var direction = tokens[2];
|
|
6303
|
+
var params = tokens[3];
|
|
6304
|
+
return new RidLine(id, direction, params);
|
|
6305
|
+
}
|
|
6306
|
+
toSdpLine() {
|
|
6307
|
+
var str = '';
|
|
6308
|
+
str += "a=rid:".concat(this.id, " ").concat(this.direction);
|
|
6309
|
+
if (this.params) {
|
|
6310
|
+
str += " ".concat(this.params);
|
|
6311
|
+
}
|
|
6312
|
+
return str;
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
_a$1 = RidLine;
|
|
6316
|
+
RidLine.RID_ID = "[\\w-]+";
|
|
6317
|
+
RidLine.RID_DIRECTION = "\\bsend\\b|\\brecv\\b";
|
|
6318
|
+
RidLine.regex = new RegExp("^rid:(".concat(_a$1.RID_ID, ") (").concat(_a$1.RID_DIRECTION, ")(?:").concat(SP, "(").concat(REST, "))?"));
|
|
6319
|
+
class RtcpMuxLine extends Line {
|
|
6320
|
+
static fromSdpLine(line) {
|
|
6321
|
+
if (!RtcpMuxLine.regex.test(line)) {
|
|
6322
|
+
return undefined;
|
|
6323
|
+
}
|
|
6324
|
+
return new RtcpMuxLine();
|
|
6325
|
+
}
|
|
6326
|
+
toSdpLine() {
|
|
6327
|
+
return "a=rtcp-mux";
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
RtcpMuxLine.regex = /^rtcp-mux$/;
|
|
6331
|
+
class RtcpFbLine extends Line {
|
|
6332
|
+
constructor(payloadType, feedback) {
|
|
6333
|
+
super();
|
|
6334
|
+
this.payloadType = payloadType;
|
|
6335
|
+
this.feedback = feedback;
|
|
6336
|
+
}
|
|
6337
|
+
static fromSdpLine(line) {
|
|
6338
|
+
if (!RtcpFbLine.regex.test(line)) {
|
|
6339
|
+
return undefined;
|
|
6340
|
+
}
|
|
6341
|
+
var tokens = line.match(RtcpFbLine.regex);
|
|
6342
|
+
var payloadType = parseInt(tokens[1], 10);
|
|
6343
|
+
var feedback = tokens[2];
|
|
6344
|
+
return new RtcpFbLine(payloadType, feedback);
|
|
6345
|
+
}
|
|
6346
|
+
toSdpLine() {
|
|
6347
|
+
return "a=rtcp-fb:".concat(this.payloadType, " ").concat(this.feedback);
|
|
6348
|
+
}
|
|
6349
|
+
}
|
|
6350
|
+
RtcpFbLine.regex = new RegExp("^rtcp-fb:(".concat(NUM, ") (").concat(REST, ")"));
|
|
6351
|
+
var _a$6;
|
|
6352
|
+
class RtpMapLine extends Line {
|
|
6353
|
+
constructor(payloadType, encodingName, clockRate, encodingParams) {
|
|
6354
|
+
super();
|
|
6355
|
+
this.payloadType = payloadType;
|
|
6356
|
+
this.encodingName = encodingName;
|
|
6357
|
+
this.clockRate = clockRate;
|
|
6358
|
+
this.encodingParams = encodingParams;
|
|
6359
|
+
}
|
|
6360
|
+
static fromSdpLine(line) {
|
|
6361
|
+
if (!RtpMapLine.regex.test(line)) {
|
|
6362
|
+
return undefined;
|
|
6363
|
+
}
|
|
6364
|
+
var tokens = line.match(RtpMapLine.regex);
|
|
6365
|
+
var payloadType = parseInt(tokens[1], 10);
|
|
6366
|
+
var encodingName = tokens[2];
|
|
6367
|
+
var clockRate = parseInt(tokens[3], 10);
|
|
6368
|
+
var encodingParams = tokens[4];
|
|
6369
|
+
return new RtpMapLine(payloadType, encodingName, clockRate, encodingParams);
|
|
6370
|
+
}
|
|
6371
|
+
toSdpLine() {
|
|
6372
|
+
var str = '';
|
|
6373
|
+
str += "a=rtpmap:".concat(this.payloadType, " ").concat(this.encodingName, "/").concat(this.clockRate);
|
|
6374
|
+
if (this.encodingParams) {
|
|
6375
|
+
str += "/".concat(this.encodingParams);
|
|
6376
|
+
}
|
|
6377
|
+
return str;
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
_a$6 = RtpMapLine;
|
|
6381
|
+
RtpMapLine.NON_SLASH_TOKEN = '[^\\s/]+';
|
|
6382
|
+
RtpMapLine.regex = new RegExp("^rtpmap:(".concat(NUM, ") (").concat(_a$6.NON_SLASH_TOKEN, ")/(").concat(_a$6.NON_SLASH_TOKEN, ")(?:/(").concat(_a$6.NON_SLASH_TOKEN, "))?"));
|
|
6383
|
+
class SctpPortLine extends Line {
|
|
6384
|
+
constructor(port) {
|
|
6385
|
+
super();
|
|
6386
|
+
this.port = port;
|
|
6387
|
+
}
|
|
6388
|
+
static fromSdpLine(line) {
|
|
6389
|
+
if (!SctpPortLine.regex.test(line)) {
|
|
6390
|
+
return undefined;
|
|
6391
|
+
}
|
|
6392
|
+
var tokens = line.match(SctpPortLine.regex);
|
|
6393
|
+
var port = parseInt(tokens[1], 10);
|
|
6394
|
+
return new SctpPortLine(port);
|
|
6395
|
+
}
|
|
6396
|
+
toSdpLine() {
|
|
6397
|
+
return "a=sctp-port:".concat(this.port);
|
|
6398
|
+
}
|
|
6399
|
+
}
|
|
6400
|
+
SctpPortLine.regex = new RegExp("^sctp-port:(".concat(NUM, ")"));
|
|
6401
|
+
class SessionInformationLine extends Line {
|
|
6402
|
+
constructor(info) {
|
|
6403
|
+
super();
|
|
6404
|
+
this.info = info;
|
|
6405
|
+
}
|
|
6406
|
+
static fromSdpLine(line) {
|
|
6407
|
+
if (!SessionInformationLine.regex.test(line)) {
|
|
6408
|
+
return undefined;
|
|
6409
|
+
}
|
|
6410
|
+
var tokens = line.match(SessionInformationLine.regex);
|
|
6411
|
+
var info = tokens[1];
|
|
6412
|
+
return new SessionInformationLine(info);
|
|
6413
|
+
}
|
|
6414
|
+
toSdpLine() {
|
|
6415
|
+
return "i=".concat(this.info);
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
SessionInformationLine.regex = new RegExp("(".concat(REST, ")"));
|
|
6419
|
+
class SessionNameLine extends Line {
|
|
6420
|
+
constructor(name) {
|
|
6421
|
+
super();
|
|
6422
|
+
this.name = name;
|
|
6423
|
+
}
|
|
6424
|
+
static fromSdpLine(line) {
|
|
6425
|
+
if (!SessionNameLine.regex.test(line)) {
|
|
6426
|
+
return undefined;
|
|
6427
|
+
}
|
|
6428
|
+
var tokens = line.match(SessionNameLine.regex);
|
|
6429
|
+
var name = tokens[1];
|
|
6430
|
+
return new SessionNameLine(name);
|
|
6431
|
+
}
|
|
6432
|
+
toSdpLine() {
|
|
6433
|
+
return "s=".concat(this.name);
|
|
6434
|
+
}
|
|
6435
|
+
}
|
|
6436
|
+
SessionNameLine.regex = new RegExp("^(".concat(REST, ")"));
|
|
6437
|
+
class SetupLine extends Line {
|
|
6438
|
+
constructor(setup) {
|
|
6439
|
+
super();
|
|
6440
|
+
this.setup = setup;
|
|
6441
|
+
}
|
|
6442
|
+
static fromSdpLine(line) {
|
|
6443
|
+
if (!SetupLine.regex.test(line)) {
|
|
6444
|
+
return undefined;
|
|
6445
|
+
}
|
|
6446
|
+
var tokens = line.match(SetupLine.regex);
|
|
6447
|
+
var setup = tokens[1];
|
|
6448
|
+
return new SetupLine(setup);
|
|
6449
|
+
}
|
|
6450
|
+
toSdpLine() {
|
|
6451
|
+
return "a=setup:".concat(this.setup);
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
SetupLine.regex = /^setup:(actpass|active|passive)$/;
|
|
6455
|
+
class SimulcastLayer {
|
|
6456
|
+
constructor(id, paused) {
|
|
6457
|
+
this.id = id;
|
|
6458
|
+
this.paused = paused;
|
|
6459
|
+
}
|
|
6460
|
+
toString() {
|
|
6461
|
+
return this.paused ? "~".concat(this.id) : this.id;
|
|
6462
|
+
}
|
|
6463
|
+
}
|
|
6464
|
+
class SimulcastLayerList {
|
|
6465
|
+
constructor() {
|
|
6466
|
+
this.layers = [];
|
|
6467
|
+
}
|
|
6468
|
+
addLayer(layer) {
|
|
6469
|
+
this.layers.push([layer]);
|
|
6470
|
+
}
|
|
6471
|
+
addLayerWithAlternatives(alternatives) {
|
|
6472
|
+
this.layers.push(alternatives);
|
|
6473
|
+
}
|
|
6474
|
+
get length() {
|
|
6475
|
+
return this.layers.length;
|
|
6476
|
+
}
|
|
6477
|
+
get(index) {
|
|
6478
|
+
return this.layers[index];
|
|
6479
|
+
}
|
|
6480
|
+
static fromString(str) {
|
|
6481
|
+
var layerList = new SimulcastLayerList();
|
|
6482
|
+
var tokens = str.split(';');
|
|
6483
|
+
if (tokens.length === 1 && !tokens[0].trim()) {
|
|
6484
|
+
throw new Error('simulcast stream list empty');
|
|
6485
|
+
}
|
|
6486
|
+
tokens.forEach(token => {
|
|
6487
|
+
if (!token) {
|
|
6488
|
+
throw new Error('simulcast layer list empty');
|
|
6489
|
+
}
|
|
6490
|
+
var ridTokens = token.split(',');
|
|
6491
|
+
var layers = [];
|
|
6492
|
+
ridTokens.forEach(ridToken => {
|
|
6493
|
+
if (!ridToken || ridToken === '~') {
|
|
6494
|
+
throw new Error('rid empty');
|
|
6495
|
+
}
|
|
6496
|
+
var paused = ridToken[0] === '~';
|
|
6497
|
+
var rid = paused ? ridToken.substring(1) : ridToken;
|
|
6498
|
+
layers.push(new SimulcastLayer(rid, paused));
|
|
6499
|
+
});
|
|
6500
|
+
layerList.addLayerWithAlternatives(layers);
|
|
6501
|
+
});
|
|
6502
|
+
return layerList;
|
|
6503
|
+
}
|
|
6504
|
+
toString() {
|
|
6505
|
+
return this.layers.map(altArray => altArray.map(v => v.toString()).join(',')).join(';');
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
class SimulcastLine extends Line {
|
|
6509
|
+
constructor(sendLayers, recvLayers) {
|
|
6510
|
+
super();
|
|
6511
|
+
this.sendLayers = sendLayers;
|
|
6512
|
+
this.recvLayers = recvLayers;
|
|
6513
|
+
}
|
|
6514
|
+
static fromSdpLine(line) {
|
|
6515
|
+
if (!SimulcastLine.regex.test(line)) {
|
|
6516
|
+
return undefined;
|
|
6517
|
+
}
|
|
6518
|
+
var tokens = line.match(SimulcastLine.regex);
|
|
6519
|
+
var bidirectional = tokens[3] && tokens[4];
|
|
6520
|
+
var firstDirection = tokens[1];
|
|
6521
|
+
var layerList1 = SimulcastLayerList.fromString(tokens[2]);
|
|
6522
|
+
var layerList2 = new SimulcastLayerList();
|
|
6523
|
+
if (bidirectional) {
|
|
6524
|
+
var secondDirection = tokens[3];
|
|
6525
|
+
if (firstDirection === secondDirection) {
|
|
6526
|
+
return undefined;
|
|
6527
|
+
}
|
|
6528
|
+
layerList2 = SimulcastLayerList.fromString(tokens[4]);
|
|
6529
|
+
}
|
|
6530
|
+
var sendLayerList;
|
|
6531
|
+
var recvLayerList;
|
|
6532
|
+
if (firstDirection === 'send') {
|
|
6533
|
+
sendLayerList = layerList1;
|
|
6534
|
+
recvLayerList = layerList2;
|
|
6535
|
+
} else {
|
|
6536
|
+
sendLayerList = layerList2;
|
|
6537
|
+
recvLayerList = layerList1;
|
|
6538
|
+
}
|
|
6539
|
+
return new SimulcastLine(sendLayerList, recvLayerList);
|
|
6540
|
+
}
|
|
6541
|
+
toSdpLine() {
|
|
6542
|
+
var str = 'a=simulcast:';
|
|
6543
|
+
if (this.sendLayers.length) {
|
|
6544
|
+
str += "send ".concat(this.sendLayers.toString());
|
|
6545
|
+
if (this.recvLayers.length) {
|
|
6546
|
+
str += " ";
|
|
6547
|
+
}
|
|
6548
|
+
}
|
|
6549
|
+
if (this.recvLayers.length) {
|
|
6550
|
+
str += "recv ".concat(this.recvLayers.toString());
|
|
6551
|
+
}
|
|
6552
|
+
return str;
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
SimulcastLine.regex = new RegExp("^simulcast:(send|recv) (".concat(ANY_NON_WS, ")(?: (send|recv) (").concat(ANY_NON_WS, "))?"));
|
|
6556
|
+
class SsrcLine extends Line {
|
|
6557
|
+
constructor(ssrcId, attribute) {
|
|
6558
|
+
var attributeValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
6559
|
+
var attributeData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
6560
|
+
super();
|
|
6561
|
+
this.ssrcId = ssrcId;
|
|
6562
|
+
this.attribute = attribute;
|
|
6563
|
+
this.attributeValue = attributeValue;
|
|
6564
|
+
this.attributeData = attributeData;
|
|
6565
|
+
}
|
|
6566
|
+
static fromSdpLine(line) {
|
|
6567
|
+
if (!SsrcLine.regex.test(line)) {
|
|
6568
|
+
return undefined;
|
|
6569
|
+
}
|
|
6570
|
+
var tokens = line.match(SsrcLine.regex);
|
|
6571
|
+
var ssrcId = parseInt(tokens[1], 10);
|
|
6572
|
+
var attribute = tokens[2];
|
|
6573
|
+
var attributeValue = tokens[3];
|
|
6574
|
+
var attributeData = tokens[4];
|
|
6575
|
+
return new SsrcLine(ssrcId, attribute, attributeValue, attributeData);
|
|
6576
|
+
}
|
|
6577
|
+
toSdpLine() {
|
|
6578
|
+
var str = "a=ssrc:".concat(this.ssrcId, " ").concat(this.attribute);
|
|
6579
|
+
if (this.attributeValue) {
|
|
6580
|
+
str += ":".concat(this.attributeValue);
|
|
6581
|
+
}
|
|
6582
|
+
if (this.attributeData) {
|
|
6583
|
+
str += " ".concat(this.attributeData);
|
|
6584
|
+
}
|
|
6585
|
+
return str;
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
SsrcLine.regex = new RegExp("^ssrc:(".concat(NUM, ") (").concat(SDP_TOKEN, ")(?::(").concat(SDP_TOKEN, ")?(?: (").concat(ANY_NON_WS, "))?)?$"));
|
|
6589
|
+
class SsrcGroupLine extends Line {
|
|
6590
|
+
constructor(semantics, ssrcs) {
|
|
6591
|
+
super();
|
|
6592
|
+
this.semantics = semantics;
|
|
6593
|
+
this.ssrcs = ssrcs;
|
|
6594
|
+
}
|
|
6595
|
+
static fromSdpLine(line) {
|
|
6596
|
+
if (!SsrcGroupLine.regex.test(line)) {
|
|
6597
|
+
return undefined;
|
|
6598
|
+
}
|
|
6599
|
+
var tokens = line.match(SsrcGroupLine.regex);
|
|
6600
|
+
var semantics = tokens[1];
|
|
6601
|
+
var ssrcs = tokens[2].split(' ').map(ssrcStr => parseInt(ssrcStr, 10));
|
|
6602
|
+
return new SsrcGroupLine(semantics, ssrcs);
|
|
6603
|
+
}
|
|
6604
|
+
toSdpLine() {
|
|
6605
|
+
return "a=ssrc-group:".concat(this.semantics, " ").concat(this.ssrcs.join(' '));
|
|
6606
|
+
}
|
|
6607
|
+
}
|
|
6608
|
+
SsrcGroupLine.regex = new RegExp("^ssrc-group:(SIM|FID|FEC) ((?:".concat(NUM).concat(SP, "*)+)"));
|
|
6609
|
+
class TimingLine extends Line {
|
|
6610
|
+
constructor(startTime, stopTime) {
|
|
6611
|
+
super();
|
|
6612
|
+
this.startTime = startTime;
|
|
6613
|
+
this.stopTime = stopTime;
|
|
6614
|
+
}
|
|
6615
|
+
static fromSdpLine(line) {
|
|
6616
|
+
if (!TimingLine.regex.test(line)) {
|
|
6617
|
+
return undefined;
|
|
6618
|
+
}
|
|
6619
|
+
var tokens = line.match(TimingLine.regex);
|
|
6620
|
+
var startTime = parseInt(tokens[1], 10);
|
|
6621
|
+
var stopTime = parseInt(tokens[2], 10);
|
|
6622
|
+
return new TimingLine(startTime, stopTime);
|
|
6623
|
+
}
|
|
6624
|
+
toSdpLine() {
|
|
6625
|
+
return "t=".concat(this.startTime, " ").concat(this.stopTime);
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6628
|
+
TimingLine.regex = new RegExp("^(".concat(NUM, ") (").concat(NUM, ")"));
|
|
6629
|
+
class VersionLine extends Line {
|
|
6630
|
+
constructor(version) {
|
|
6631
|
+
super();
|
|
6632
|
+
this.version = version;
|
|
6633
|
+
}
|
|
6634
|
+
static fromSdpLine(line) {
|
|
6635
|
+
if (!VersionLine.regex.test(line)) {
|
|
6636
|
+
return undefined;
|
|
6637
|
+
}
|
|
6638
|
+
var tokens = line.match(VersionLine.regex);
|
|
6639
|
+
var version = parseInt(tokens[1], 10);
|
|
6640
|
+
return new VersionLine(version);
|
|
6641
|
+
}
|
|
6642
|
+
toSdpLine() {
|
|
6643
|
+
return "v=".concat(this.version);
|
|
6644
|
+
}
|
|
6645
|
+
}
|
|
6646
|
+
VersionLine.regex = new RegExp("^(".concat(NUM, ")$"));
|
|
6647
|
+
class UnknownLine extends Line {
|
|
6648
|
+
constructor(value) {
|
|
6649
|
+
super();
|
|
6650
|
+
this.value = value;
|
|
6651
|
+
}
|
|
6652
|
+
static fromSdpLine(line) {
|
|
6653
|
+
var tokens = line.match(UnknownLine.regex);
|
|
6654
|
+
var value = tokens[1];
|
|
6655
|
+
return new UnknownLine(value);
|
|
6656
|
+
}
|
|
6657
|
+
toSdpLine() {
|
|
6658
|
+
return "".concat(this.value);
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
UnknownLine.regex = new RegExp("(".concat(REST, ")"));
|
|
6662
|
+
class IceInfo {
|
|
6663
|
+
constructor() {
|
|
6664
|
+
this.candidates = [];
|
|
6665
|
+
}
|
|
6666
|
+
addLine(line) {
|
|
6667
|
+
if (line instanceof IceUfragLine) {
|
|
6668
|
+
this.ufrag = line;
|
|
6669
|
+
return true;
|
|
6670
|
+
}
|
|
6671
|
+
if (line instanceof IcePwdLine) {
|
|
6672
|
+
this.pwd = line;
|
|
6673
|
+
return true;
|
|
6674
|
+
}
|
|
6675
|
+
if (line instanceof IceOptionsLine) {
|
|
6676
|
+
this.options = line;
|
|
6677
|
+
return true;
|
|
6678
|
+
}
|
|
6679
|
+
if (line instanceof CandidateLine) {
|
|
6680
|
+
this.candidates.push(line);
|
|
6681
|
+
return true;
|
|
6682
|
+
}
|
|
6683
|
+
return false;
|
|
6684
|
+
}
|
|
6685
|
+
toLines() {
|
|
6686
|
+
var lines = [];
|
|
6687
|
+
if (this.ufrag) {
|
|
6688
|
+
lines.push(this.ufrag);
|
|
6689
|
+
}
|
|
6690
|
+
if (this.pwd) {
|
|
6691
|
+
lines.push(this.pwd);
|
|
6692
|
+
}
|
|
6693
|
+
if (this.options) {
|
|
6694
|
+
lines.push(this.options);
|
|
6695
|
+
}
|
|
6696
|
+
this.candidates.forEach(candidate => lines.push(candidate));
|
|
6697
|
+
return lines;
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
class MediaDescription {
|
|
6701
|
+
constructor(type, port, protocol) {
|
|
6702
|
+
this.iceInfo = new IceInfo();
|
|
6703
|
+
this.otherLines = [];
|
|
6704
|
+
this.type = type;
|
|
6705
|
+
this.port = port;
|
|
6706
|
+
this.protocol = protocol;
|
|
6707
|
+
}
|
|
6708
|
+
findOtherLine(ty) {
|
|
6709
|
+
return this.otherLines.find(line => line instanceof ty);
|
|
6710
|
+
}
|
|
6711
|
+
addLine(line) {
|
|
6712
|
+
if (line instanceof BundleGroupLine) {
|
|
6713
|
+
throw new Error("Error: bundle group line not allowed in media description");
|
|
6714
|
+
}
|
|
6715
|
+
if (line instanceof BandwidthLine) {
|
|
6716
|
+
this.bandwidth = line;
|
|
6717
|
+
return true;
|
|
6718
|
+
}
|
|
6719
|
+
if (line instanceof MidLine) {
|
|
6720
|
+
this.mid = line.mid;
|
|
6721
|
+
return true;
|
|
6722
|
+
}
|
|
6723
|
+
if (line instanceof FingerprintLine) {
|
|
6724
|
+
this.fingerprint = line.fingerprint;
|
|
6725
|
+
return true;
|
|
6726
|
+
}
|
|
6727
|
+
if (line instanceof SetupLine) {
|
|
6728
|
+
this.setup = line.setup;
|
|
6729
|
+
return true;
|
|
6730
|
+
}
|
|
6731
|
+
if (line instanceof ConnectionLine) {
|
|
6732
|
+
this.connection = line;
|
|
6733
|
+
return true;
|
|
6734
|
+
}
|
|
6735
|
+
if (line instanceof ContentLine) {
|
|
6736
|
+
this.content = line;
|
|
6737
|
+
return true;
|
|
6738
|
+
}
|
|
6739
|
+
return this.iceInfo.addLine(line);
|
|
6740
|
+
}
|
|
6741
|
+
}
|
|
6742
|
+
class ApplicationMediaDescription extends MediaDescription {
|
|
6743
|
+
constructor(mediaLine) {
|
|
6744
|
+
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
6745
|
+
this.fmts = [];
|
|
6746
|
+
this.fmts = mediaLine.formats;
|
|
6747
|
+
}
|
|
6748
|
+
toLines() {
|
|
6749
|
+
var lines = [];
|
|
6750
|
+
lines.push(new MediaLine(this.type, this.port, this.protocol, this.fmts));
|
|
6751
|
+
if (this.connection) {
|
|
6752
|
+
lines.push(this.connection);
|
|
6753
|
+
}
|
|
6754
|
+
if (this.bandwidth) {
|
|
6755
|
+
lines.push(this.bandwidth);
|
|
6756
|
+
}
|
|
6757
|
+
lines.push(...this.iceInfo.toLines());
|
|
6758
|
+
if (this.fingerprint) {
|
|
6759
|
+
lines.push(new FingerprintLine(this.fingerprint));
|
|
6760
|
+
}
|
|
6761
|
+
if (this.setup) {
|
|
6762
|
+
lines.push(new SetupLine(this.setup));
|
|
6763
|
+
}
|
|
6764
|
+
if (this.mid) {
|
|
6765
|
+
lines.push(new MidLine(this.mid));
|
|
6766
|
+
}
|
|
6767
|
+
if (this.content) {
|
|
6768
|
+
lines.push(this.content);
|
|
6769
|
+
}
|
|
6770
|
+
if (this.sctpPort) {
|
|
6771
|
+
lines.push(new SctpPortLine(this.sctpPort));
|
|
6772
|
+
}
|
|
6773
|
+
if (this.maxMessageSize) {
|
|
6774
|
+
lines.push(new MaxMessageSizeLine(this.maxMessageSize));
|
|
6775
|
+
}
|
|
6776
|
+
lines.push(...this.otherLines);
|
|
6777
|
+
return lines;
|
|
6778
|
+
}
|
|
6779
|
+
addLine(line) {
|
|
6780
|
+
if (super.addLine(line)) {
|
|
6781
|
+
return true;
|
|
6782
|
+
}
|
|
6783
|
+
if (line instanceof MediaLine) {
|
|
6784
|
+
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
6785
|
+
}
|
|
6786
|
+
if (line instanceof SctpPortLine) {
|
|
6787
|
+
this.sctpPort = line.port;
|
|
6788
|
+
return true;
|
|
6789
|
+
}
|
|
6790
|
+
if (line instanceof MaxMessageSizeLine) {
|
|
6791
|
+
this.maxMessageSize = line.maxMessageSize;
|
|
6792
|
+
return true;
|
|
6793
|
+
}
|
|
6794
|
+
this.otherLines.push(line);
|
|
6795
|
+
return true;
|
|
6796
|
+
}
|
|
6797
|
+
}
|
|
6798
|
+
class CodecInfo$1 {
|
|
6799
|
+
constructor(pt) {
|
|
6800
|
+
this.fmtParams = new Map();
|
|
6801
|
+
this.feedback = [];
|
|
6802
|
+
this.pt = pt;
|
|
6803
|
+
}
|
|
6804
|
+
addLine(line) {
|
|
6805
|
+
if (line instanceof RtpMapLine) {
|
|
6806
|
+
this.name = line.encodingName;
|
|
6807
|
+
this.clockRate = line.clockRate;
|
|
6808
|
+
this.encodingParams = line.encodingParams;
|
|
6809
|
+
return true;
|
|
6810
|
+
}
|
|
6811
|
+
if (line instanceof FmtpLine) {
|
|
6812
|
+
this.fmtParams = new Map([...Array.from(this.fmtParams.entries()), ...Array.from(line.params.entries())]);
|
|
6813
|
+
if (line.params.has('apt')) {
|
|
6814
|
+
var apt = line.params.get('apt');
|
|
6815
|
+
this.primaryCodecPt = parseInt(apt, 10);
|
|
6816
|
+
}
|
|
6817
|
+
return true;
|
|
6818
|
+
}
|
|
6819
|
+
if (line instanceof RtcpFbLine) {
|
|
6820
|
+
this.feedback.push(line.feedback);
|
|
6821
|
+
return true;
|
|
6822
|
+
}
|
|
6823
|
+
return false;
|
|
6824
|
+
}
|
|
6825
|
+
toLines() {
|
|
6826
|
+
var lines = [];
|
|
6827
|
+
if (this.name && this.clockRate) {
|
|
6828
|
+
lines.push(new RtpMapLine(this.pt, this.name, this.clockRate, this.encodingParams));
|
|
6829
|
+
}
|
|
6830
|
+
this.feedback.forEach(fb => {
|
|
6831
|
+
lines.push(new RtcpFbLine(this.pt, fb));
|
|
6832
|
+
});
|
|
6833
|
+
if (this.fmtParams.size > 0) {
|
|
6834
|
+
lines.push(new FmtpLine(this.pt, this.fmtParams));
|
|
6835
|
+
}
|
|
6836
|
+
return lines;
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
class AvMediaDescription extends MediaDescription {
|
|
6840
|
+
constructor(mediaLine) {
|
|
6841
|
+
super(mediaLine.type, mediaLine.port, mediaLine.protocol);
|
|
6842
|
+
this.pts = [];
|
|
6843
|
+
this.extMaps = [];
|
|
6844
|
+
this.rids = [];
|
|
6845
|
+
this.codecs = new Map();
|
|
6846
|
+
this.rtcpMux = false;
|
|
6847
|
+
this.ssrcs = [];
|
|
6848
|
+
this.ssrcGroups = [];
|
|
6849
|
+
this.pts = mediaLine.formats.map(fmt => {
|
|
6850
|
+
return parseInt(fmt, 10);
|
|
6851
|
+
});
|
|
6852
|
+
this.pts.forEach(pt => this.codecs.set(pt, new CodecInfo$1(pt)));
|
|
6853
|
+
}
|
|
6854
|
+
toLines() {
|
|
6855
|
+
var lines = [];
|
|
6856
|
+
lines.push(new MediaLine(this.type, this.port, this.protocol, this.pts.map(pt => "".concat(pt))));
|
|
6857
|
+
if (this.connection) {
|
|
6858
|
+
lines.push(this.connection);
|
|
6859
|
+
}
|
|
6860
|
+
if (this.bandwidth) {
|
|
6861
|
+
lines.push(this.bandwidth);
|
|
6862
|
+
}
|
|
6863
|
+
lines.push(...this.iceInfo.toLines());
|
|
6864
|
+
if (this.fingerprint) {
|
|
6865
|
+
lines.push(new FingerprintLine(this.fingerprint));
|
|
6866
|
+
}
|
|
6867
|
+
if (this.setup) {
|
|
6868
|
+
lines.push(new SetupLine(this.setup));
|
|
6869
|
+
}
|
|
6870
|
+
if (this.mid) {
|
|
6871
|
+
lines.push(new MidLine(this.mid));
|
|
6872
|
+
}
|
|
6873
|
+
if (this.rtcpMux) {
|
|
6874
|
+
lines.push(new RtcpMuxLine());
|
|
6875
|
+
}
|
|
6876
|
+
if (this.content) {
|
|
6877
|
+
lines.push(this.content);
|
|
6878
|
+
}
|
|
6879
|
+
this.extMaps.forEach(extMap => lines.push(extMap));
|
|
6880
|
+
this.rids.forEach(rid => lines.push(rid));
|
|
6881
|
+
if (this.simulcast) {
|
|
6882
|
+
lines.push(this.simulcast);
|
|
6883
|
+
}
|
|
6884
|
+
if (this.direction) {
|
|
6885
|
+
lines.push(new DirectionLine(this.direction));
|
|
6886
|
+
}
|
|
6887
|
+
this.codecs.forEach(codec => lines.push(...codec.toLines()));
|
|
6888
|
+
lines.push(...this.ssrcs);
|
|
6889
|
+
lines.push(...this.ssrcGroups);
|
|
6890
|
+
lines.push(...this.otherLines);
|
|
6891
|
+
return lines;
|
|
6892
|
+
}
|
|
6893
|
+
addLine(line) {
|
|
6894
|
+
if (super.addLine(line)) {
|
|
6895
|
+
return true;
|
|
6896
|
+
}
|
|
6897
|
+
if (line instanceof MediaLine) {
|
|
6898
|
+
throw new Error('Error: tried passing a MediaLine to an existing MediaInfo');
|
|
6899
|
+
}
|
|
6900
|
+
if (line instanceof DirectionLine) {
|
|
6901
|
+
this.direction = line.direction;
|
|
6902
|
+
return true;
|
|
6903
|
+
}
|
|
6904
|
+
if (line instanceof ExtMapLine) {
|
|
6905
|
+
this.extMaps.push(line);
|
|
6906
|
+
return true;
|
|
6907
|
+
}
|
|
6908
|
+
if (line instanceof RidLine) {
|
|
6909
|
+
this.rids.push(line);
|
|
6910
|
+
return true;
|
|
6911
|
+
}
|
|
6912
|
+
if (line instanceof RtcpMuxLine) {
|
|
6913
|
+
this.rtcpMux = true;
|
|
6914
|
+
return true;
|
|
6915
|
+
}
|
|
6916
|
+
if (line instanceof SimulcastLine) {
|
|
6917
|
+
this.simulcast = line;
|
|
6918
|
+
return true;
|
|
6919
|
+
}
|
|
6920
|
+
if (line instanceof RtpMapLine || line instanceof FmtpLine || line instanceof RtcpFbLine) {
|
|
6921
|
+
var codec = this.codecs.get(line.payloadType);
|
|
6922
|
+
if (!codec) {
|
|
6923
|
+
throw new Error("Error: got line for unknown codec: ".concat(line.toSdpLine()));
|
|
6924
|
+
}
|
|
6925
|
+
codec.addLine(line);
|
|
6926
|
+
return true;
|
|
6927
|
+
}
|
|
6928
|
+
if (line instanceof SsrcLine) {
|
|
6929
|
+
this.ssrcs.push(line);
|
|
6930
|
+
return true;
|
|
6931
|
+
}
|
|
6932
|
+
if (line instanceof SsrcGroupLine) {
|
|
6933
|
+
this.ssrcGroups.push(line);
|
|
6934
|
+
return true;
|
|
6935
|
+
}
|
|
6936
|
+
this.otherLines.push(line);
|
|
6937
|
+
return true;
|
|
6938
|
+
}
|
|
6939
|
+
getCodecByPt(pt) {
|
|
6940
|
+
return this.codecs.get(pt);
|
|
6941
|
+
}
|
|
6942
|
+
removePt(pt) {
|
|
6943
|
+
var associatedPts = [...this.codecs.values()].filter(ci => ci.primaryCodecPt === pt).map(ci => ci.pt);
|
|
6944
|
+
var allPtsToRemove = [pt, ...associatedPts];
|
|
6945
|
+
allPtsToRemove.forEach(ptToRemove => {
|
|
6946
|
+
this.codecs.delete(ptToRemove);
|
|
6947
|
+
});
|
|
6948
|
+
this.pts = this.pts.filter(existingPt => allPtsToRemove.indexOf(existingPt) === -1);
|
|
6949
|
+
}
|
|
6950
|
+
}
|
|
6951
|
+
class SessionDescription {
|
|
6952
|
+
constructor() {
|
|
6953
|
+
this.groups = [];
|
|
6954
|
+
this.otherLines = [];
|
|
6955
|
+
}
|
|
6956
|
+
addLine(line) {
|
|
6957
|
+
if (line instanceof VersionLine) {
|
|
6958
|
+
this.version = line;
|
|
6959
|
+
return true;
|
|
6960
|
+
}
|
|
6961
|
+
if (line instanceof OriginLine) {
|
|
6962
|
+
this.origin = line;
|
|
6963
|
+
return true;
|
|
6964
|
+
}
|
|
6965
|
+
if (line instanceof SessionNameLine) {
|
|
6966
|
+
this.sessionName = line;
|
|
6967
|
+
return true;
|
|
6968
|
+
}
|
|
6969
|
+
if (line instanceof SessionInformationLine) {
|
|
6970
|
+
this.information = line;
|
|
6971
|
+
return true;
|
|
6972
|
+
}
|
|
6973
|
+
if (line instanceof TimingLine) {
|
|
6974
|
+
this.timing = line;
|
|
6975
|
+
return true;
|
|
6976
|
+
}
|
|
6977
|
+
if (line instanceof ConnectionLine) {
|
|
6978
|
+
this.connection = line;
|
|
6979
|
+
return true;
|
|
6980
|
+
}
|
|
6981
|
+
if (line instanceof BandwidthLine) {
|
|
6982
|
+
this.bandwidth = line;
|
|
6983
|
+
return true;
|
|
6984
|
+
}
|
|
6985
|
+
if (line instanceof BundleGroupLine) {
|
|
6986
|
+
this.groups.push(line);
|
|
6987
|
+
return true;
|
|
6988
|
+
}
|
|
6989
|
+
this.otherLines.push(line);
|
|
6990
|
+
return true;
|
|
6991
|
+
}
|
|
6992
|
+
toLines() {
|
|
6993
|
+
var lines = [];
|
|
6994
|
+
if (this.version) {
|
|
6995
|
+
lines.push(this.version);
|
|
6996
|
+
}
|
|
6997
|
+
if (this.origin) {
|
|
6998
|
+
lines.push(this.origin);
|
|
6999
|
+
}
|
|
7000
|
+
if (this.sessionName) {
|
|
7001
|
+
lines.push(this.sessionName);
|
|
7002
|
+
}
|
|
7003
|
+
if (this.information) {
|
|
7004
|
+
lines.push(this.information);
|
|
7005
|
+
}
|
|
7006
|
+
if (this.connection) {
|
|
7007
|
+
lines.push(this.connection);
|
|
7008
|
+
}
|
|
7009
|
+
if (this.bandwidth) {
|
|
7010
|
+
lines.push(this.bandwidth);
|
|
7011
|
+
}
|
|
7012
|
+
if (this.timing) {
|
|
7013
|
+
lines.push(this.timing);
|
|
7014
|
+
}
|
|
7015
|
+
if (this.groups) {
|
|
7016
|
+
lines.push(...this.groups);
|
|
7017
|
+
}
|
|
7018
|
+
lines.push(...this.otherLines);
|
|
7019
|
+
return lines;
|
|
7020
|
+
}
|
|
7021
|
+
}
|
|
7022
|
+
class Sdp {
|
|
7023
|
+
constructor() {
|
|
7024
|
+
this.session = new SessionDescription();
|
|
7025
|
+
this.media = [];
|
|
7026
|
+
}
|
|
7027
|
+
get avMedia() {
|
|
7028
|
+
return this.media.filter(mi => mi instanceof AvMediaDescription);
|
|
7029
|
+
}
|
|
7030
|
+
toString() {
|
|
7031
|
+
var lines = [];
|
|
7032
|
+
lines.push(...this.session.toLines());
|
|
7033
|
+
this.media.forEach(m => lines.push(...m.toLines()));
|
|
7034
|
+
return "".concat(lines.map(l => l.toSdpLine()).join('\r\n'), "\r\n");
|
|
7035
|
+
}
|
|
7036
|
+
}
|
|
7037
|
+
class Grammar {
|
|
7038
|
+
constructor() {
|
|
7039
|
+
this.parsers = new Map();
|
|
7040
|
+
}
|
|
7041
|
+
addParser(lineType, parser) {
|
|
7042
|
+
var parsers = this.parsers.get(lineType) || [];
|
|
7043
|
+
parsers.push(parser);
|
|
7044
|
+
this.parsers.set(lineType, parsers);
|
|
7045
|
+
}
|
|
7046
|
+
getParsers(lineType) {
|
|
7047
|
+
return this.parsers.get(lineType) || [];
|
|
7048
|
+
}
|
|
7049
|
+
}
|
|
7050
|
+
class SdpGrammar extends Grammar {
|
|
7051
|
+
constructor() {
|
|
7052
|
+
super();
|
|
7053
|
+
this.addParser('v', VersionLine.fromSdpLine);
|
|
7054
|
+
this.addParser('o', OriginLine.fromSdpLine);
|
|
7055
|
+
this.addParser('c', ConnectionLine.fromSdpLine);
|
|
7056
|
+
this.addParser('i', SessionInformationLine.fromSdpLine);
|
|
7057
|
+
this.addParser('m', MediaLine.fromSdpLine);
|
|
7058
|
+
this.addParser('s', SessionNameLine.fromSdpLine);
|
|
7059
|
+
this.addParser('t', TimingLine.fromSdpLine);
|
|
7060
|
+
this.addParser('b', BandwidthLine.fromSdpLine);
|
|
7061
|
+
this.addParser('a', RtpMapLine.fromSdpLine);
|
|
7062
|
+
this.addParser('a', RtcpFbLine.fromSdpLine);
|
|
7063
|
+
this.addParser('a', FmtpLine.fromSdpLine);
|
|
7064
|
+
this.addParser('a', DirectionLine.fromSdpLine);
|
|
7065
|
+
this.addParser('a', ExtMapLine.fromSdpLine);
|
|
7066
|
+
this.addParser('a', MidLine.fromSdpLine);
|
|
7067
|
+
this.addParser('a', IceUfragLine.fromSdpLine);
|
|
7068
|
+
this.addParser('a', IcePwdLine.fromSdpLine);
|
|
7069
|
+
this.addParser('a', IceOptionsLine.fromSdpLine);
|
|
7070
|
+
this.addParser('a', FingerprintLine.fromSdpLine);
|
|
7071
|
+
this.addParser('a', SetupLine.fromSdpLine);
|
|
7072
|
+
this.addParser('a', SctpPortLine.fromSdpLine);
|
|
7073
|
+
this.addParser('a', MaxMessageSizeLine.fromSdpLine);
|
|
7074
|
+
this.addParser('a', RtcpMuxLine.fromSdpLine);
|
|
7075
|
+
this.addParser('a', BundleGroupLine.fromSdpLine);
|
|
7076
|
+
this.addParser('a', ContentLine.fromSdpLine);
|
|
7077
|
+
this.addParser('a', RidLine.fromSdpLine);
|
|
7078
|
+
this.addParser('a', CandidateLine.fromSdpLine);
|
|
7079
|
+
this.addParser('a', SimulcastLine.fromSdpLine);
|
|
7080
|
+
this.addParser('a', SsrcLine.fromSdpLine);
|
|
7081
|
+
this.addParser('a', SsrcGroupLine.fromSdpLine);
|
|
7082
|
+
}
|
|
7083
|
+
}
|
|
7084
|
+
var DefaultSdpGrammar = new SdpGrammar();
|
|
7085
|
+
function isValidLine(line) {
|
|
7086
|
+
return line.length > 2;
|
|
7087
|
+
}
|
|
7088
|
+
function parseToModel(lines) {
|
|
7089
|
+
var sdp = new Sdp();
|
|
7090
|
+
var currBlock = sdp.session;
|
|
7091
|
+
lines.forEach(l => {
|
|
7092
|
+
if (l instanceof MediaLine) {
|
|
7093
|
+
var mediaInfo;
|
|
7094
|
+
if (l.type === 'audio' || l.type === 'video') {
|
|
7095
|
+
mediaInfo = new AvMediaDescription(l);
|
|
7096
|
+
} else if (l.type === 'application') {
|
|
7097
|
+
mediaInfo = new ApplicationMediaDescription(l);
|
|
7098
|
+
} else {
|
|
7099
|
+
throw new Error("Unhandled media type: ".concat(l.type));
|
|
7100
|
+
}
|
|
7101
|
+
sdp.media.push(mediaInfo);
|
|
7102
|
+
currBlock = mediaInfo;
|
|
7103
|
+
} else {
|
|
7104
|
+
currBlock.addLine(l);
|
|
7105
|
+
}
|
|
7106
|
+
});
|
|
7107
|
+
return sdp;
|
|
7108
|
+
}
|
|
7109
|
+
function parseToLines(sdp, grammar) {
|
|
7110
|
+
var lines = [];
|
|
7111
|
+
sdp.split(/(\r\n|\r|\n)/).filter(isValidLine).forEach(l => {
|
|
7112
|
+
var lineType = l[0];
|
|
7113
|
+
var lineValue = l.slice(2);
|
|
7114
|
+
var parsers = grammar.getParsers(lineType);
|
|
7115
|
+
for (var parser of parsers) {
|
|
7116
|
+
var _result = parser(lineValue);
|
|
7117
|
+
if (_result) {
|
|
7118
|
+
lines.push(_result);
|
|
7119
|
+
return;
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7122
|
+
var result = UnknownLine.fromSdpLine(l);
|
|
7123
|
+
lines.push(result);
|
|
7124
|
+
});
|
|
7125
|
+
return lines;
|
|
7126
|
+
}
|
|
7127
|
+
function parse(sdp) {
|
|
7128
|
+
var grammar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DefaultSdpGrammar;
|
|
7129
|
+
var lines = parseToLines(sdp, grammar);
|
|
7130
|
+
var parsed = parseToModel(lines);
|
|
7131
|
+
return parsed;
|
|
7132
|
+
}
|
|
7133
|
+
|
|
7134
|
+
function getLocalTrackInfo(kind, direction, localTrack) {
|
|
7135
|
+
return {
|
|
7136
|
+
trackOrKind: localTrack || kind,
|
|
7137
|
+
direction
|
|
7138
|
+
};
|
|
7139
|
+
}
|
|
7140
|
+
function hasH264Codec(mediaLine) {
|
|
7141
|
+
for (var codec of mediaLine.codecs.values()) {
|
|
7142
|
+
var _codec$name;
|
|
7143
|
+
if (((_codec$name = codec.name) === null || _codec$name === void 0 ? void 0 : _codec$name.toUpperCase()) === 'H264') {
|
|
7144
|
+
return true;
|
|
7145
|
+
}
|
|
7146
|
+
}
|
|
7147
|
+
return false;
|
|
7148
|
+
}
|
|
7149
|
+
function checkSdpForErrors(options, sdp) {
|
|
7150
|
+
if (!sdp) {
|
|
7151
|
+
return new Error('SDP is missing');
|
|
7152
|
+
}
|
|
7153
|
+
var parsedSdp = parse(sdp);
|
|
7154
|
+
for (var mediaLine of parsedSdp.avMedia) {
|
|
7155
|
+
if (!mediaLine.iceInfo.candidates.length) {
|
|
7156
|
+
return new IceGatheringError("ice candidates missing for m-line with mid=".concat(mediaLine.mid));
|
|
7157
|
+
}
|
|
7158
|
+
if (!options.allowPort0 && mediaLine.port === 0) {
|
|
7159
|
+
return new SdpError("Found invalid port number 0 at m-line with mid=".concat(mediaLine.mid));
|
|
7160
|
+
}
|
|
7161
|
+
if (!mediaLine.iceInfo.pwd || !mediaLine.iceInfo.ufrag) {
|
|
7162
|
+
return new IceGatheringError("ice ufrag and password not found for m-line with mid=".concat(mediaLine.mid));
|
|
7163
|
+
}
|
|
7164
|
+
if (options.requireH264 && mediaLine.type === 'video' && !hasH264Codec(mediaLine)) {
|
|
7165
|
+
return new SdpError("H264 codec is missing for video media description with mid=".concat(mediaLine.mid));
|
|
7166
|
+
}
|
|
7167
|
+
}
|
|
7168
|
+
return false;
|
|
7169
|
+
}
|
|
7170
|
+
function convertCLineToIPv4(sdp) {
|
|
7171
|
+
var convertConnectionProp = connection => {
|
|
7172
|
+
if ((connection === null || connection === void 0 ? void 0 : connection.addrType) === 'IP6') {
|
|
7173
|
+
connection.addrType = 'IP4';
|
|
7174
|
+
connection.ipAddr = '0.0.0.0';
|
|
7175
|
+
}
|
|
7176
|
+
};
|
|
7177
|
+
convertConnectionProp(sdp.session.connection);
|
|
7178
|
+
sdp.media.forEach(media => {
|
|
7179
|
+
convertConnectionProp(media.connection);
|
|
7180
|
+
});
|
|
7181
|
+
}
|
|
7182
|
+
function convertPort9to0(sdp) {
|
|
7183
|
+
sdp.media.forEach(media => {
|
|
7184
|
+
if (media.port === 9) {
|
|
7185
|
+
media.port = 0;
|
|
7186
|
+
}
|
|
7187
|
+
});
|
|
7188
|
+
}
|
|
7189
|
+
function setContentSlides(sdp) {
|
|
7190
|
+
var videoMediaDescriptions = sdp.avMedia.filter(media => media.type === 'video');
|
|
7191
|
+
if (videoMediaDescriptions.length === 2) {
|
|
7192
|
+
videoMediaDescriptions[1].addLine(new ContentLine(['slides']));
|
|
7193
|
+
}
|
|
7194
|
+
}
|
|
7195
|
+
class AnyLine extends Line {
|
|
7196
|
+
constructor(value) {
|
|
7197
|
+
super();
|
|
7198
|
+
_defineProperty__default["default"](this, "value", void 0);
|
|
7199
|
+
this.value = value;
|
|
7200
|
+
}
|
|
7201
|
+
static fromSdpLine() {
|
|
7202
|
+
return undefined;
|
|
7203
|
+
}
|
|
7204
|
+
toSdpLine() {
|
|
7205
|
+
return "a=".concat(this.value);
|
|
7206
|
+
}
|
|
7207
|
+
}
|
|
7208
|
+
function addBandwidthLimits(sdp, limits) {
|
|
7209
|
+
sdp.avMedia.forEach(media => {
|
|
7210
|
+
if (media.type === 'audio') {
|
|
7211
|
+
media.addLine(new BandwidthLine('TIAS', limits.audio));
|
|
7212
|
+
} else if (media.type === 'video') {
|
|
7213
|
+
media.addLine(new BandwidthLine('TIAS', limits.video));
|
|
7214
|
+
}
|
|
7215
|
+
});
|
|
7216
|
+
}
|
|
7217
|
+
function addPeriodicKeyframes(sdp, value) {
|
|
7218
|
+
sdp.avMedia.forEach(media => {
|
|
7219
|
+
if (media.type === 'video') {
|
|
7220
|
+
media.addLine(new AnyLine("periodic-keyframes:".concat(value)));
|
|
7221
|
+
}
|
|
7222
|
+
});
|
|
7223
|
+
}
|
|
7224
|
+
function disableExtmap(sdp) {
|
|
7225
|
+
sdp.avMedia.forEach(media => {
|
|
7226
|
+
media.extMaps.length = 0;
|
|
7227
|
+
});
|
|
7228
|
+
}
|
|
7229
|
+
function updateH264fmtpParams(sdp, paramsToUpdate) {
|
|
7230
|
+
sdp.avMedia.forEach(media => {
|
|
7231
|
+
if (media.type === 'video') {
|
|
7232
|
+
media.codecs.forEach(codec => {
|
|
7233
|
+
var _codec$name2;
|
|
7234
|
+
if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
|
|
7235
|
+
paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
|
|
7236
|
+
}
|
|
7237
|
+
});
|
|
7238
|
+
}
|
|
7239
|
+
});
|
|
7240
|
+
}
|
|
7241
|
+
function adjustH264Profile(sdp, maxFsValue) {
|
|
7242
|
+
var maxFsForProfileLevel = {
|
|
7243
|
+
10: 99,
|
|
7244
|
+
11: 396,
|
|
7245
|
+
12: 396,
|
|
7246
|
+
13: 396,
|
|
7247
|
+
20: 396,
|
|
7248
|
+
21: 792,
|
|
7249
|
+
22: 1620,
|
|
7250
|
+
30: 1620,
|
|
7251
|
+
31: 3600,
|
|
7252
|
+
32: 5120,
|
|
7253
|
+
40: 8192,
|
|
7254
|
+
41: 8192,
|
|
7255
|
+
42: 8704,
|
|
7256
|
+
50: 22080,
|
|
7257
|
+
51: 36864,
|
|
7258
|
+
52: 36864,
|
|
7259
|
+
60: 139264,
|
|
7260
|
+
61: 139264,
|
|
7261
|
+
62: 139264
|
|
7262
|
+
};
|
|
7263
|
+
var framesPerSecond = 30;
|
|
7264
|
+
sdp.avMedia.forEach(media => {
|
|
7265
|
+
if (media.type === 'video') {
|
|
7266
|
+
media.codecs.forEach(codec => {
|
|
7267
|
+
var _codec$name3;
|
|
7268
|
+
if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
|
|
7269
|
+
var profileLevelIdValue = codec.fmtParams.get('profile-level-id');
|
|
7270
|
+
if (profileLevelIdValue) {
|
|
7271
|
+
var profile = profileLevelIdValue.substring(0, 4).toLowerCase();
|
|
7272
|
+
var levelId = parseInt(profileLevelIdValue.substring(4, 6), 16);
|
|
7273
|
+
if (!maxFsForProfileLevel[levelId]) {
|
|
7274
|
+
throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
|
|
7275
|
+
}
|
|
7276
|
+
if (maxFsForProfileLevel[levelId] === maxFsValue) {
|
|
7277
|
+
return;
|
|
7278
|
+
}
|
|
7279
|
+
if (maxFsForProfileLevel[levelId] < maxFsValue) {
|
|
7280
|
+
codec.fmtParams.set('max-fs', "".concat(maxFsValue));
|
|
7281
|
+
codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
|
|
7282
|
+
return;
|
|
7283
|
+
}
|
|
7284
|
+
var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
|
|
7285
|
+
if (newLevelId) {
|
|
7286
|
+
var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
|
|
7287
|
+
codec.fmtParams.set('profile-level-id', "".concat(profile).concat(newLevelIdHex));
|
|
7288
|
+
codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
|
|
7289
|
+
return;
|
|
7290
|
+
}
|
|
7291
|
+
throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
});
|
|
7295
|
+
}
|
|
7296
|
+
});
|
|
7297
|
+
}
|
|
7298
|
+
function disableRtx(sdp) {
|
|
7299
|
+
sdp.avMedia.forEach(media => {
|
|
7300
|
+
var payloadTypesToRemove = [];
|
|
7301
|
+
media.codecs.forEach((codec, codecPt) => {
|
|
7302
|
+
if (codec.name === 'rtx' && codec.primaryCodecPt) {
|
|
7303
|
+
payloadTypesToRemove.push(codecPt);
|
|
7304
|
+
}
|
|
7305
|
+
});
|
|
7306
|
+
payloadTypesToRemove.forEach(pt => media.codecs.delete(pt));
|
|
7307
|
+
media.pts = media.pts.filter(pt => !payloadTypesToRemove.includes(pt));
|
|
7308
|
+
});
|
|
7309
|
+
}
|
|
7310
|
+
function mungeLocalSdpForBrowser(config, sdp) {
|
|
7311
|
+
var parsedSdp = parse(sdp);
|
|
7312
|
+
if (config.disableRtx) {
|
|
7313
|
+
disableRtx(parsedSdp);
|
|
7314
|
+
}
|
|
7315
|
+
return parsedSdp.toString();
|
|
7316
|
+
}
|
|
7317
|
+
function mungeLocalSdp(config, sdp) {
|
|
7318
|
+
var parsedSdp = parse(sdp);
|
|
7319
|
+
if (config.convertCLineToIPv4) {
|
|
7320
|
+
convertCLineToIPv4(parsedSdp);
|
|
7321
|
+
}
|
|
7322
|
+
if (config.bandwidthLimits) {
|
|
7323
|
+
addBandwidthLimits(parsedSdp, config.bandwidthLimits);
|
|
7324
|
+
}
|
|
7325
|
+
if (config.periodicKeyframes) {
|
|
7326
|
+
addPeriodicKeyframes(parsedSdp, config.periodicKeyframes);
|
|
7327
|
+
}
|
|
7328
|
+
if (config.convertPort9to0) {
|
|
7329
|
+
convertPort9to0(parsedSdp);
|
|
7330
|
+
}
|
|
7331
|
+
if (config.addContentSlides) {
|
|
7332
|
+
setContentSlides(parsedSdp);
|
|
7333
|
+
}
|
|
7334
|
+
if (config.disableExtmap) {
|
|
7335
|
+
disableExtmap(parsedSdp);
|
|
7336
|
+
}
|
|
7337
|
+
if (config.h264MaxFs) {
|
|
7338
|
+
adjustH264Profile(parsedSdp, config.h264MaxFs);
|
|
7339
|
+
}
|
|
7340
|
+
return parsedSdp.toString();
|
|
7341
|
+
}
|
|
7342
|
+
function setStartBitrate(sdp, startBitrate) {
|
|
7343
|
+
updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
|
|
7344
|
+
}
|
|
7345
|
+
function removeXtlsIceCandidates(sdp) {
|
|
7346
|
+
sdp.media.forEach(media => {
|
|
7347
|
+
media.iceInfo.candidates = media.iceInfo.candidates.filter(candidate => candidate.transport.toLowerCase() !== 'xtls');
|
|
7348
|
+
});
|
|
7349
|
+
}
|
|
7350
|
+
function mungeRemoteSdp(config, sdp) {
|
|
7351
|
+
var parsedSdp = parse(sdp);
|
|
7352
|
+
if (config.startBitrate) {
|
|
7353
|
+
setStartBitrate(parsedSdp, config.startBitrate);
|
|
7354
|
+
}
|
|
7355
|
+
if (config.disableExtmap) {
|
|
7356
|
+
disableExtmap(parsedSdp);
|
|
7357
|
+
}
|
|
7358
|
+
removeXtlsIceCandidates(parsedSdp);
|
|
7359
|
+
return parsedSdp.toString();
|
|
7360
|
+
}
|
|
7343
7361
|
|
|
7344
7362
|
exports.Event = void 0;
|
|
7345
7363
|
(function (Event) {
|
|
@@ -7393,12 +7411,14 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7393
7411
|
_defineProperty__default["default"](this, "pc", void 0);
|
|
7394
7412
|
_defineProperty__default["default"](this, "localTracks", void 0);
|
|
7395
7413
|
_defineProperty__default["default"](this, "transceivers", void 0);
|
|
7396
|
-
_defineProperty__default["default"](this, "
|
|
7414
|
+
_defineProperty__default["default"](this, "mediaDirection", void 0);
|
|
7415
|
+
_defineProperty__default["default"](this, "remoteQualityLevel", void 0);
|
|
7397
7416
|
_defineProperty__default["default"](this, "mediaConnectionState", void 0);
|
|
7398
7417
|
_defineProperty__default["default"](this, "lastEmittedMediaConnectionState", void 0);
|
|
7399
7418
|
this.config = mediaConnectionConfig;
|
|
7400
|
-
this.
|
|
7401
|
-
this.localTracks = _objectSpread$3({}, options.
|
|
7419
|
+
this.mediaDirection = _objectSpread$3({}, options.direction);
|
|
7420
|
+
this.localTracks = _objectSpread$3({}, options.localTracks);
|
|
7421
|
+
this.remoteQualityLevel = options.remoteQualityLevel;
|
|
7402
7422
|
this.id = debugId || 'MediaConnection';
|
|
7403
7423
|
this.transceivers = {};
|
|
7404
7424
|
this.mediaConnectionState = exports.ConnectionState.New;
|
|
@@ -7427,7 +7447,7 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7427
7447
|
} = _ref;
|
|
7428
7448
|
var trackType = type;
|
|
7429
7449
|
var transceiverType = type;
|
|
7430
|
-
var trackInfo = getLocalTrackInfo(kind, this.
|
|
7450
|
+
var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
|
|
7431
7451
|
if (!this.config.skipInactiveTransceivers || trackInfo.direction !== 'inactive') {
|
|
7432
7452
|
this.transceivers[transceiverType] = this.pc.addTransceiver(trackInfo.trackOrKind, {
|
|
7433
7453
|
direction: trackInfo.direction
|
|
@@ -7461,22 +7481,23 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7461
7481
|
}
|
|
7462
7482
|
getSendReceiveOptions() {
|
|
7463
7483
|
return {
|
|
7464
|
-
|
|
7465
|
-
|
|
7484
|
+
localTracks: this.localTracks,
|
|
7485
|
+
direction: this.mediaDirection,
|
|
7486
|
+
remoteQualityLevel: this.remoteQualityLevel
|
|
7466
7487
|
};
|
|
7467
7488
|
}
|
|
7468
7489
|
updateRemoteQualityLevel(newValue) {
|
|
7469
|
-
if (newValue !== this.
|
|
7470
|
-
this.
|
|
7490
|
+
if (newValue !== this.remoteQualityLevel) {
|
|
7491
|
+
this.remoteQualityLevel = newValue;
|
|
7471
7492
|
return true;
|
|
7472
7493
|
}
|
|
7473
7494
|
return false;
|
|
7474
7495
|
}
|
|
7475
7496
|
updateTransceivers(options) {
|
|
7476
7497
|
var newOfferNeeded = false;
|
|
7477
|
-
this.
|
|
7478
|
-
this.
|
|
7479
|
-
this.
|
|
7498
|
+
this.mediaDirection.audio = options.direction.audio;
|
|
7499
|
+
this.mediaDirection.video = options.direction.video;
|
|
7500
|
+
this.mediaDirection.screenShareVideo = options.direction.screenShareVideo;
|
|
7480
7501
|
this.identifyTransceivers();
|
|
7481
7502
|
localTrackTypes.forEach(_ref2 => {
|
|
7482
7503
|
var {
|
|
@@ -7485,7 +7506,7 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7485
7506
|
} = _ref2;
|
|
7486
7507
|
var trackType = type;
|
|
7487
7508
|
var transceiverType = type;
|
|
7488
|
-
var track = options.
|
|
7509
|
+
var track = options.localTracks[trackType];
|
|
7489
7510
|
var transceiver = this.transceivers[transceiverType];
|
|
7490
7511
|
if (track !== undefined && track !== this.localTracks[trackType]) {
|
|
7491
7512
|
this.localTracks[trackType] = track;
|
|
@@ -7495,7 +7516,7 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7495
7516
|
}
|
|
7496
7517
|
}
|
|
7497
7518
|
if (transceiver) {
|
|
7498
|
-
var trackInfo = getLocalTrackInfo(kind, this.
|
|
7519
|
+
var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
|
|
7499
7520
|
if (transceiver.direction !== trackInfo.direction) {
|
|
7500
7521
|
this.log('updateTransceivers()', "updating direction to ".concat(trackInfo.direction, " on \"").concat(type, "\" transceiver"));
|
|
7501
7522
|
transceiver.direction = trackInfo.direction;
|
|
@@ -7505,28 +7526,21 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7505
7526
|
});
|
|
7506
7527
|
return newOfferNeeded;
|
|
7507
7528
|
}
|
|
7508
|
-
|
|
7529
|
+
updateLocalTracks(tracks) {
|
|
7509
7530
|
return this.updateTransceivers({
|
|
7510
|
-
|
|
7511
|
-
|
|
7531
|
+
localTracks: tracks,
|
|
7532
|
+
direction: _objectSpread$3({}, this.mediaDirection)
|
|
7512
7533
|
});
|
|
7513
7534
|
}
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
}
|
|
7519
|
-
if (this.updateTransceivers({
|
|
7520
|
-
send: this.localTracks,
|
|
7521
|
-
receive: options
|
|
7522
|
-
})) {
|
|
7523
|
-
sdpNegotiationNeeded = true;
|
|
7524
|
-
}
|
|
7525
|
-
return sdpNegotiationNeeded;
|
|
7535
|
+
updateDirection(direction) {
|
|
7536
|
+
return this.updateTransceivers({
|
|
7537
|
+
localTracks: this.localTracks,
|
|
7538
|
+
direction
|
|
7539
|
+
});
|
|
7526
7540
|
}
|
|
7527
|
-
|
|
7541
|
+
update(options) {
|
|
7528
7542
|
var sdpNegotiationNeeded = false;
|
|
7529
|
-
if (this.updateRemoteQualityLevel(options.
|
|
7543
|
+
if (this.updateRemoteQualityLevel(options.remoteQualityLevel)) {
|
|
7530
7544
|
sdpNegotiationNeeded = true;
|
|
7531
7545
|
}
|
|
7532
7546
|
if (this.updateTransceivers(options)) {
|
|
@@ -7724,20 +7738,20 @@ class MediaConnection extends EventEmitter$3 {
|
|
|
7724
7738
|
}
|
|
7725
7739
|
}
|
|
7726
7740
|
createSdpMungingConfig() {
|
|
7727
|
-
if (this.
|
|
7741
|
+
if (this.remoteQualityLevel) {
|
|
7728
7742
|
var maxFsValues = {
|
|
7729
7743
|
LOW: 1620,
|
|
7730
7744
|
MEDIUM: 3600,
|
|
7731
7745
|
HIGH: 8192
|
|
7732
7746
|
};
|
|
7733
|
-
if (!maxFsValues[this.
|
|
7734
|
-
throw new Error("invalid value for receiveOptions.remoteQualityLevel: ".concat(this.
|
|
7747
|
+
if (!maxFsValues[this.remoteQualityLevel]) {
|
|
7748
|
+
throw new Error("invalid value for receiveOptions.remoteQualityLevel: ".concat(this.remoteQualityLevel));
|
|
7735
7749
|
}
|
|
7736
7750
|
if (this.config.sdpMunging.h264MaxFs) {
|
|
7737
7751
|
this.warn('createSdpMungingConfig', 'conflict: both config.sdpMunging.h264MaxFs and receiveOptions.remoteQualityLevel are set, remoteQualityLevel will override the config');
|
|
7738
7752
|
}
|
|
7739
7753
|
return _objectSpread$3(_objectSpread$3({}, this.config.sdpMunging), {}, {
|
|
7740
|
-
h264MaxFs: maxFsValues[this.
|
|
7754
|
+
h264MaxFs: maxFsValues[this.remoteQualityLevel]
|
|
7741
7755
|
});
|
|
7742
7756
|
}
|
|
7743
7757
|
return this.config.sdpMunging;
|
|
@@ -15792,6 +15806,7 @@ class RoapMediaConnection extends EventEmitter$3 {
|
|
|
15792
15806
|
this.debugId = debugId;
|
|
15793
15807
|
this.id = debugId || 'RoapMediaConnection';
|
|
15794
15808
|
this.sdpNegotiationStarted = false;
|
|
15809
|
+
configureWcmeLogger(debugId);
|
|
15795
15810
|
this.log('constructor()', "config: ".concat(JSON.stringify(mediaConnectionConfig), ", options: ").concat(JSON.stringify(options)));
|
|
15796
15811
|
this.mediaConnection = this.createMediaConnection(mediaConnectionConfig, options, debugId);
|
|
15797
15812
|
this.roap = this.createRoap(debugId);
|
|
@@ -15858,29 +15873,38 @@ class RoapMediaConnection extends EventEmitter$3 {
|
|
|
15858
15873
|
}
|
|
15859
15874
|
return Promise.resolve();
|
|
15860
15875
|
}
|
|
15861
|
-
|
|
15862
|
-
this.log('
|
|
15863
|
-
var newOfferNeeded = this.mediaConnection.
|
|
15876
|
+
updateLocalTracks(tracks) {
|
|
15877
|
+
this.log('updateLocalTracks()', "called with ".concat(JSON.stringify(tracks)));
|
|
15878
|
+
var newOfferNeeded = this.mediaConnection.updateLocalTracks(tracks);
|
|
15879
|
+
if (newOfferNeeded) {
|
|
15880
|
+
this.log('updateLocalTracks()', 'triggering offer...');
|
|
15881
|
+
return this.roap.initiateOffer();
|
|
15882
|
+
}
|
|
15883
|
+
return Promise.resolve();
|
|
15884
|
+
}
|
|
15885
|
+
updateDirection(direction) {
|
|
15886
|
+
this.log('updateDirection()', "called with ".concat(JSON.stringify(direction)));
|
|
15887
|
+
var newOfferNeeded = this.mediaConnection.updateDirection(direction);
|
|
15864
15888
|
if (newOfferNeeded) {
|
|
15865
|
-
this.log('
|
|
15889
|
+
this.log('updateDirection()', 'triggering offer...');
|
|
15866
15890
|
return this.roap.initiateOffer();
|
|
15867
15891
|
}
|
|
15868
15892
|
return Promise.resolve();
|
|
15869
15893
|
}
|
|
15870
|
-
|
|
15871
|
-
this.log('
|
|
15872
|
-
var newOfferNeeded = this.mediaConnection.
|
|
15894
|
+
updateRemoteQualityLevel(newValue) {
|
|
15895
|
+
this.log('updateRemoteQualityLevel()', "called with ".concat(newValue));
|
|
15896
|
+
var newOfferNeeded = this.mediaConnection.updateRemoteQualityLevel(newValue);
|
|
15873
15897
|
if (newOfferNeeded) {
|
|
15874
|
-
this.log('
|
|
15898
|
+
this.log('updateRemoteQualityLevel()', 'triggering offer...');
|
|
15875
15899
|
return this.roap.initiateOffer();
|
|
15876
15900
|
}
|
|
15877
15901
|
return Promise.resolve();
|
|
15878
15902
|
}
|
|
15879
|
-
|
|
15880
|
-
this.log('
|
|
15881
|
-
var newOfferNeeded = this.mediaConnection.
|
|
15903
|
+
update(options) {
|
|
15904
|
+
this.log('update()', "called with ".concat(JSON.stringify(options)));
|
|
15905
|
+
var newOfferNeeded = this.mediaConnection.update(options);
|
|
15882
15906
|
if (newOfferNeeded) {
|
|
15883
|
-
this.log('
|
|
15907
|
+
this.log('update()', 'triggering offer...');
|
|
15884
15908
|
return this.roap.initiateOffer();
|
|
15885
15909
|
}
|
|
15886
15910
|
return Promise.resolve();
|
|
@@ -16302,35 +16326,11 @@ class MultistreamRoapMediaConnection extends EventEmitter$4 {
|
|
|
16302
16326
|
_defineProperty__default["default"](this, "sdpNegotiationStarted", false);
|
|
16303
16327
|
this.debugId = debugId;
|
|
16304
16328
|
this.id = debugId || 'MultistreamRoapMediaConnection';
|
|
16305
|
-
|
|
16329
|
+
configureWcmeLogger(debugId);
|
|
16306
16330
|
this.log('constructor()', "config: ".concat(JSON.stringify(mediaConnectionConfig)));
|
|
16307
16331
|
this.multistreamConnection = this.createMultistreamConnection(mediaConnectionConfig);
|
|
16308
16332
|
this.roap = this.createRoap(debugId);
|
|
16309
16333
|
}
|
|
16310
|
-
configureWcmeLogger(debugId) {
|
|
16311
|
-
var logger = getLogger();
|
|
16312
|
-
setLogHandler((messages, context) => {
|
|
16313
|
-
var logMessages = Array.from(messages).map(message => typeof message === 'object' ? JSON.stringify(message) : message);
|
|
16314
|
-
logMessages.unshift("".concat(debugId || '', ":[").concat(context.name, "]"));
|
|
16315
|
-
switch (context.level.name) {
|
|
16316
|
-
case 'TRACE':
|
|
16317
|
-
logger.trace(...logMessages);
|
|
16318
|
-
break;
|
|
16319
|
-
case 'DEBUG':
|
|
16320
|
-
logger.debug(...logMessages);
|
|
16321
|
-
break;
|
|
16322
|
-
case 'INFO':
|
|
16323
|
-
logger.info(...logMessages);
|
|
16324
|
-
break;
|
|
16325
|
-
case 'WARN':
|
|
16326
|
-
logger.warn(...logMessages);
|
|
16327
|
-
break;
|
|
16328
|
-
case 'ERROR':
|
|
16329
|
-
logger.error(...logMessages);
|
|
16330
|
-
break;
|
|
16331
|
-
}
|
|
16332
|
-
});
|
|
16333
|
-
}
|
|
16334
16334
|
log(action, description) {
|
|
16335
16335
|
getLogger().info("".concat(this.id, ":").concat(action, " ").concat(description));
|
|
16336
16336
|
}
|
|
@@ -16532,6 +16532,7 @@ exports.ReceiverSelectedInfo = ReceiverSelectedInfo;
|
|
|
16532
16532
|
exports.RoapMediaConnection = RoapMediaConnection;
|
|
16533
16533
|
exports.StreamRequest = StreamRequest;
|
|
16534
16534
|
exports.WcmeError = WcmeError;
|
|
16535
|
+
exports.configureWcmeLogger = configureWcmeLogger;
|
|
16535
16536
|
exports.createCameraTrack = createCameraTrack;
|
|
16536
16537
|
exports.createDisplayTrack = createDisplayTrack;
|
|
16537
16538
|
exports.createMicrophoneTrack = createMicrophoneTrack;
|