@webex/internal-media-core 1.35.3 → 1.35.4

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 CHANGED
@@ -2933,6 +2933,22 @@ class FingerprintLine$1 extends Line$1 {
2933
2933
  }
2934
2934
  }
2935
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
+ }
2936
2952
  class FmtpLine$1 extends Line$1 {
2937
2953
  constructor(payloadType, params) {
2938
2954
  super();
@@ -2946,10 +2962,16 @@ class FmtpLine$1 extends Line$1 {
2946
2962
  var tokens = line.match(FmtpLine$1.regex);
2947
2963
  var payloadType = parseInt(tokens[1], 10);
2948
2964
  var params = tokens[2];
2949
- return new FmtpLine$1(payloadType, params);
2965
+ return new FmtpLine$1(payloadType, parseFmtpParams$1(params));
2950
2966
  }
2951
2967
  toSdpLine() {
2952
- return "a=fmtp:".concat(this.payloadType, " ").concat(this.params);
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);
2953
2975
  }
2954
2976
  }
2955
2977
  FmtpLine$1.regex = new RegExp("^fmtp:(".concat(NUM$1, ") (").concat(REST$1, ")"));
@@ -3610,7 +3632,7 @@ class ApplicationMediaDescription$1 extends MediaDescription$1 {
3610
3632
  }
3611
3633
  class CodecInfo$2 {
3612
3634
  constructor(pt) {
3613
- this.fmtParams = [];
3635
+ this.fmtParams = new Map();
3614
3636
  this.feedback = [];
3615
3637
  this.pt = pt;
3616
3638
  }
@@ -3622,9 +3644,9 @@ class CodecInfo$2 {
3622
3644
  return true;
3623
3645
  }
3624
3646
  if (line instanceof FmtpLine$1) {
3625
- this.fmtParams.push(line.params);
3626
- if (line.params.indexOf('apt') !== -1) {
3627
- var apt = line.params.split('=')[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');
3628
3650
  this.primaryCodecPt = parseInt(apt, 10);
3629
3651
  }
3630
3652
  return true;
@@ -3637,13 +3659,15 @@ class CodecInfo$2 {
3637
3659
  }
3638
3660
  toLines() {
3639
3661
  var lines = [];
3640
- lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3662
+ if (this.name && this.clockRate) {
3663
+ lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3664
+ }
3641
3665
  this.feedback.forEach(fb => {
3642
3666
  lines.push(new RtcpFbLine$1(this.pt, fb));
3643
3667
  });
3644
- this.fmtParams.forEach(fmt => {
3645
- lines.push(new FmtpLine$1(this.pt, fmt));
3646
- });
3668
+ if (this.fmtParams.size > 0) {
3669
+ lines.push(new FmtpLine$1(this.pt, this.fmtParams));
3670
+ }
3647
3671
  return lines;
3648
3672
  }
3649
3673
  }
@@ -4044,13 +4068,13 @@ function disableExtmap(sdp) {
4044
4068
  media.extMaps.length = 0;
4045
4069
  });
4046
4070
  }
4047
- function appendToH264fmtpParams(sdp, paramsToAppend) {
4071
+ function updateH264fmtpParams(sdp, paramsToUpdate) {
4048
4072
  sdp.avMedia.forEach(media => {
4049
4073
  if (media.type === 'video') {
4050
4074
  media.codecs.forEach(codec => {
4051
4075
  var _codec$name2;
4052
4076
  if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
4053
- codec.fmtParams = codec.fmtParams.map(fmtp => "".concat(fmtp, ";").concat(paramsToAppend));
4077
+ paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
4054
4078
  }
4055
4079
  });
4056
4080
  }
@@ -4084,32 +4108,30 @@ function adjustH264Profile(sdp, maxFsValue) {
4084
4108
  media.codecs.forEach(codec => {
4085
4109
  var _codec$name3;
4086
4110
  if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
4087
- codec.fmtParams = codec.fmtParams.map(fmtp => {
4088
- var parsedRegex = fmtp.match(/(.*)profile-level-id=(\w{4})(\w{2})(.*)/);
4089
- if (parsedRegex && parsedRegex.length === 5) {
4090
- var stuffBeforeProfileLevelId = parsedRegex[1];
4091
- var profile = parsedRegex[2].toLowerCase();
4092
- var levelId = parseInt(parsedRegex[3], 16);
4093
- var stuffAfterProfileLevelId = parsedRegex[4];
4094
- if (!maxFsForProfileLevel[levelId]) {
4095
- throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4096
- }
4097
- if (maxFsForProfileLevel[levelId] === maxFsValue) {
4098
- return fmtp;
4099
- }
4100
- if (maxFsForProfileLevel[levelId] < maxFsValue) {
4101
- return "".concat(fmtp, ";max-fs=").concat(maxFsValue, ";max-mbps=").concat(maxFsValue * framesPerSecond);
4102
- }
4103
- var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4104
- if (newLevelId) {
4105
- var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4106
- var maxMbps = "max-mbps=".concat(maxFsValue * framesPerSecond);
4107
- return "".concat(stuffBeforeProfileLevelId, "profile-level-id=").concat(profile).concat(newLevelIdHex, ";").concat(maxMbps).concat(stuffAfterProfileLevelId);
4108
- }
4109
- throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
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));
4110
4117
  }
4111
- return fmtp;
4112
- });
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
+ }
4113
4135
  }
4114
4136
  });
4115
4137
  }
@@ -4160,7 +4182,7 @@ function mungeLocalSdp(config, sdp) {
4160
4182
  return parsedSdp.toString();
4161
4183
  }
4162
4184
  function setStartBitrate(sdp, startBitrate) {
4163
- appendToH264fmtpParams(sdp, "x-google-start-bitrate=".concat(startBitrate));
4185
+ updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
4164
4186
  }
4165
4187
  function removeXtlsIceCandidates(sdp) {
4166
4188
  sdp.media.forEach(media => {
package/dist/esm/index.js CHANGED
@@ -2922,6 +2922,22 @@ class FingerprintLine$1 extends Line$1 {
2922
2922
  }
2923
2923
  }
2924
2924
  FingerprintLine$1.regex = new RegExp("^fingerprint:(".concat(REST$1, ")"));
2925
+ function parseFmtpParams$1(fmtpParams) {
2926
+ fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
2927
+ var fmtpObj = new Map();
2928
+ if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
2929
+ fmtpObj.set(fmtpParams, undefined);
2930
+ return fmtpObj;
2931
+ }
2932
+ fmtpParams.split(';').forEach(param => {
2933
+ var paramArr = param && param.split('=');
2934
+ if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
2935
+ throw new Error("Fmtp params is invalid with ".concat(fmtpParams));
2936
+ }
2937
+ fmtpObj.set(paramArr[0], paramArr[1]);
2938
+ });
2939
+ return fmtpObj;
2940
+ }
2925
2941
  class FmtpLine$1 extends Line$1 {
2926
2942
  constructor(payloadType, params) {
2927
2943
  super();
@@ -2935,10 +2951,16 @@ class FmtpLine$1 extends Line$1 {
2935
2951
  var tokens = line.match(FmtpLine$1.regex);
2936
2952
  var payloadType = parseInt(tokens[1], 10);
2937
2953
  var params = tokens[2];
2938
- return new FmtpLine$1(payloadType, params);
2954
+ return new FmtpLine$1(payloadType, parseFmtpParams$1(params));
2939
2955
  }
2940
2956
  toSdpLine() {
2941
- return "a=fmtp:".concat(this.payloadType, " ").concat(this.params);
2957
+ var fmtParams = Array.from(this.params.keys()).map(key => {
2958
+ if (this.params.get(key) !== undefined) {
2959
+ return "".concat(key, "=").concat(this.params.get(key));
2960
+ }
2961
+ return "".concat(key);
2962
+ }).join(';');
2963
+ return "a=fmtp:".concat(this.payloadType, " ").concat(fmtParams);
2942
2964
  }
2943
2965
  }
2944
2966
  FmtpLine$1.regex = new RegExp("^fmtp:(".concat(NUM$1, ") (").concat(REST$1, ")"));
@@ -3599,7 +3621,7 @@ class ApplicationMediaDescription$1 extends MediaDescription$1 {
3599
3621
  }
3600
3622
  class CodecInfo$2 {
3601
3623
  constructor(pt) {
3602
- this.fmtParams = [];
3624
+ this.fmtParams = new Map();
3603
3625
  this.feedback = [];
3604
3626
  this.pt = pt;
3605
3627
  }
@@ -3611,9 +3633,9 @@ class CodecInfo$2 {
3611
3633
  return true;
3612
3634
  }
3613
3635
  if (line instanceof FmtpLine$1) {
3614
- this.fmtParams.push(line.params);
3615
- if (line.params.indexOf('apt') !== -1) {
3616
- var apt = line.params.split('=')[1];
3636
+ this.fmtParams = new Map([...Array.from(this.fmtParams.entries()), ...Array.from(line.params.entries())]);
3637
+ if (line.params.has('apt')) {
3638
+ var apt = line.params.get('apt');
3617
3639
  this.primaryCodecPt = parseInt(apt, 10);
3618
3640
  }
3619
3641
  return true;
@@ -3626,13 +3648,15 @@ class CodecInfo$2 {
3626
3648
  }
3627
3649
  toLines() {
3628
3650
  var lines = [];
3629
- lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3651
+ if (this.name && this.clockRate) {
3652
+ lines.push(new RtpMapLine$1(this.pt, this.name, this.clockRate, this.encodingParams));
3653
+ }
3630
3654
  this.feedback.forEach(fb => {
3631
3655
  lines.push(new RtcpFbLine$1(this.pt, fb));
3632
3656
  });
3633
- this.fmtParams.forEach(fmt => {
3634
- lines.push(new FmtpLine$1(this.pt, fmt));
3635
- });
3657
+ if (this.fmtParams.size > 0) {
3658
+ lines.push(new FmtpLine$1(this.pt, this.fmtParams));
3659
+ }
3636
3660
  return lines;
3637
3661
  }
3638
3662
  }
@@ -4033,13 +4057,13 @@ function disableExtmap(sdp) {
4033
4057
  media.extMaps.length = 0;
4034
4058
  });
4035
4059
  }
4036
- function appendToH264fmtpParams(sdp, paramsToAppend) {
4060
+ function updateH264fmtpParams(sdp, paramsToUpdate) {
4037
4061
  sdp.avMedia.forEach(media => {
4038
4062
  if (media.type === 'video') {
4039
4063
  media.codecs.forEach(codec => {
4040
4064
  var _codec$name2;
4041
4065
  if (((_codec$name2 = codec.name) === null || _codec$name2 === void 0 ? void 0 : _codec$name2.toUpperCase()) === 'H264') {
4042
- codec.fmtParams = codec.fmtParams.map(fmtp => "".concat(fmtp, ";").concat(paramsToAppend));
4066
+ paramsToUpdate.forEach((value, key) => codec.fmtParams.set(key, value));
4043
4067
  }
4044
4068
  });
4045
4069
  }
@@ -4073,32 +4097,30 @@ function adjustH264Profile(sdp, maxFsValue) {
4073
4097
  media.codecs.forEach(codec => {
4074
4098
  var _codec$name3;
4075
4099
  if (((_codec$name3 = codec.name) === null || _codec$name3 === void 0 ? void 0 : _codec$name3.toUpperCase()) === 'H264') {
4076
- codec.fmtParams = codec.fmtParams.map(fmtp => {
4077
- var parsedRegex = fmtp.match(/(.*)profile-level-id=(\w{4})(\w{2})(.*)/);
4078
- if (parsedRegex && parsedRegex.length === 5) {
4079
- var stuffBeforeProfileLevelId = parsedRegex[1];
4080
- var profile = parsedRegex[2].toLowerCase();
4081
- var levelId = parseInt(parsedRegex[3], 16);
4082
- var stuffAfterProfileLevelId = parsedRegex[4];
4083
- if (!maxFsForProfileLevel[levelId]) {
4084
- throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4085
- }
4086
- if (maxFsForProfileLevel[levelId] === maxFsValue) {
4087
- return fmtp;
4088
- }
4089
- if (maxFsForProfileLevel[levelId] < maxFsValue) {
4090
- return "".concat(fmtp, ";max-fs=").concat(maxFsValue, ";max-mbps=").concat(maxFsValue * framesPerSecond);
4091
- }
4092
- var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4093
- if (newLevelId) {
4094
- var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4095
- var maxMbps = "max-mbps=".concat(maxFsValue * framesPerSecond);
4096
- return "".concat(stuffBeforeProfileLevelId, "profile-level-id=").concat(profile).concat(newLevelIdHex, ";").concat(maxMbps).concat(stuffAfterProfileLevelId);
4097
- }
4098
- throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4100
+ var profileLevelIdValue = codec.fmtParams.get('profile-level-id');
4101
+ if (profileLevelIdValue) {
4102
+ var profile = profileLevelIdValue.substring(0, 4).toLowerCase();
4103
+ var levelId = parseInt(profileLevelIdValue.substring(4, 6), 16);
4104
+ if (!maxFsForProfileLevel[levelId]) {
4105
+ throw new Error("found unsupported h264 profile level id value in the SDP: ".concat(levelId));
4099
4106
  }
4100
- return fmtp;
4101
- });
4107
+ if (maxFsForProfileLevel[levelId] === maxFsValue) {
4108
+ return;
4109
+ }
4110
+ if (maxFsForProfileLevel[levelId] < maxFsValue) {
4111
+ codec.fmtParams.set('max-fs', "".concat(maxFsValue));
4112
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4113
+ return;
4114
+ }
4115
+ var newLevelId = Object.keys(maxFsForProfileLevel).reverse().find(key => maxFsForProfileLevel[key] === maxFsValue);
4116
+ if (newLevelId) {
4117
+ var newLevelIdHex = parseInt(newLevelId, 10).toString(16);
4118
+ codec.fmtParams.set('profile-level-id', "".concat(profile).concat(newLevelIdHex));
4119
+ codec.fmtParams.set('max-mbps', "".concat(maxFsValue * framesPerSecond));
4120
+ return;
4121
+ }
4122
+ throw new Error("unsupported maxFsValue: ".concat(maxFsValue));
4123
+ }
4102
4124
  }
4103
4125
  });
4104
4126
  }
@@ -4149,7 +4171,7 @@ function mungeLocalSdp(config, sdp) {
4149
4171
  return parsedSdp.toString();
4150
4172
  }
4151
4173
  function setStartBitrate(sdp, startBitrate) {
4152
- appendToH264fmtpParams(sdp, "x-google-start-bitrate=".concat(startBitrate));
4174
+ updateH264fmtpParams(sdp, new Map([['x-google-start-bitrate', startBitrate.toString()]]));
4153
4175
  }
4154
4176
  function removeXtlsIceCandidates(sdp) {
4155
4177
  sdp.media.forEach(media => {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/MediaConnection/utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,gBAAgB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B,EACD,GAAG,CAAC,EAAE,MAAM,GACX,KAAK,GAAG,KAAK,CA6Bf;AAkOD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQrF;AASD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA2B3E;AAcD,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAc5E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-media-core",
3
- "version": "1.35.3",
3
+ "version": "1.35.4",
4
4
  "files": [
5
5
  "dist/cjs",
6
6
  "dist/esm",
@@ -46,7 +46,7 @@
46
46
  "dependencies": {
47
47
  "@babel/runtime": "^7.18.9",
48
48
  "@webex/json-multistream": "1.20.2",
49
- "@webex/ts-sdp": "1.3.0",
49
+ "@webex/ts-sdp": "1.3.2",
50
50
  "@webex/web-client-media-engine": "1.40.2",
51
51
  "detectrtc": "^1.4.1",
52
52
  "events": "^3.3.0",